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