PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.3.4
Pods – Custom Content Types and Fields v3.3.4
trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / src / Pods / REST / V1 / Endpoints / Field_Slug.php
pods / src / Pods / REST / V1 / Endpoints Last commit date
Base.php 1 year ago Field.php 1 year ago Field_Slug.php 4 years ago Fields.php 1 year ago Group.php 1 year ago Group_Slug.php 4 years ago Groups.php 1 year ago Pod.php 1 year ago Pod_Slug.php 4 years ago Pods.php 1 year ago Swagger_Documentation.php 1 year ago
Field_Slug.php
151 lines
1 <?php
2
3 namespace Pods\REST\V1\Endpoints;
4
5 use WP_REST_Request;
6
7 class Field_Slug extends Field {
8
9 /**
10 * {@inheritdoc}
11 *
12 * @since 2.8.0
13 */
14 public $route = '/pods/%1$s/fields/%2$s';
15
16 /**
17 * {@inheritdoc}
18 *
19 * @since 2.8.11
20 */
21 public $rest_route = '/pods/(?P<pod>[\w\_\-]+)/fields/(?P<slug>[\w\_\-]+)';
22
23 /**
24 * {@inheritdoc}
25 *
26 * @since 2.8.11
27 */
28 public $rest_doc_route = '/pods/{pod}/fields/{slug}';
29
30 /**
31 * {@inheritdoc}
32 *
33 * @since 2.8.0
34 */
35 public function READ_args() {
36 return [
37 'pod' => [
38 'type' => 'string',
39 'in' => 'path',
40 'description' => __( 'The Pod slug.', 'pods' ),
41 'required' => true,
42 'validate_callback' => [ $this->validator, 'is_pod_slug' ],
43 ],
44 'slug' => [
45 'type' => 'string',
46 'in' => 'path',
47 'description' => __( 'The Field slug.', 'pods' ),
48 'required' => true,
49 ],
50 ];
51 }
52
53 /**
54 * {@inheritdoc}
55 *
56 * @since 2.8.0
57 */
58 public function get( WP_REST_Request $request ) {
59 return $this->get_by_args( 'slug', 'name', $request );
60 }
61
62 /**
63 * {@inheritdoc}
64 *
65 * @since 2.8.0
66 */
67 public function EDIT_args() {
68 return [
69 'pod' => [
70 'type' => 'string',
71 'in' => 'path',
72 'description' => __( 'The Pod slug.', 'pods' ),
73 'required' => true,
74 'validate_callback' => [ $this->validator, 'is_pod_slug' ],
75 ],
76 'slug' => [
77 'type' => 'string',
78 'in' => 'path',
79 'description' => __( 'The Field slug.', 'pods' ),
80 'required' => true,
81 ],
82 'new_name' => [
83 'type' => 'string',
84 'description' => __( 'The new name of the Field.', 'pods' ),
85 ],
86 'new_group' => [
87 'type' => 'string',
88 'description' => __( 'The new Group to use for the Field.', 'pods' ),
89 ],
90 'new_group_id' => [
91 'type' => 'string',
92 'description' => __( 'The new Group ID to use for the Field.', 'pods' ),
93 ],
94 'label' => [
95 'type' => 'string',
96 'description' => __( 'The singular label of the Field.', 'pods' ),
97 ],
98 'type' => [
99 'type' => 'string',
100 'description' => __( 'The type of the Field.', 'pods' ),
101 ],
102 'args' => [
103 'required' => false,
104 'description' => __( 'A list of additional options to save to the Field.', 'pods' ),
105 'swagger_type' => 'array',
106 ],
107 ];
108 }
109
110 /**
111 * {@inheritdoc}
112 *
113 * @since 2.8.0
114 */
115 public function update( WP_REST_Request $request ) {
116 return $this->update_by_args( 'slug', 'name', $request );
117 }
118
119 /**
120 * {@inheritdoc}
121 *
122 * @since 2.8.0
123 */
124 public function DELETE_args() {
125 return [
126 'pod' => [
127 'type' => 'string',
128 'in' => 'path',
129 'description' => __( 'The Pod slug.', 'pods' ),
130 'required' => true,
131 'validate_callback' => [ $this->validator, 'is_pod_slug' ],
132 ],
133 'slug' => [
134 'type' => 'string',
135 'in' => 'path',
136 'description' => __( 'The Field slug.', 'pods' ),
137 'required' => true,
138 ],
139 ];
140 }
141
142 /**
143 * {@inheritdoc}
144 *
145 * @since 2.8.0
146 */
147 public function delete( WP_REST_Request $request ) {
148 return $this->delete_by_args( 'slug', 'name', $request );
149 }
150 }
151