PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.2.5
Pods – Custom Content Types and Fields v3.2.5
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 / Pod_Slug.php
pods / src / Pods / REST / V1 / Endpoints Last commit date
Base.php 3 years ago Field.php 3 years ago Field_Slug.php 4 years ago Fields.php 3 years ago Group.php 3 years ago Group_Slug.php 4 years ago Groups.php 3 years ago Pod.php 3 years ago Pod_Slug.php 4 years ago Pods.php 3 years ago Swagger_Documentation.php 3 years ago
Pod_Slug.php
136 lines
1 <?php
2
3 namespace Pods\REST\V1\Endpoints;
4
5 use WP_REST_Request;
6
7 class Pod_Slug extends Pod {
8
9 /**
10 * {@inheritdoc}
11 *
12 * @since 2.8.0
13 */
14 public $route = '/pods/%1$s';
15
16 /**
17 * {@inheritdoc}
18 *
19 * @since 2.8.11
20 */
21 public $rest_route = '/pods/(?P<slug>[\w\_\-]+)';
22
23 /**
24 * {@inheritdoc}
25 *
26 * @since 2.8.11
27 */
28 public $rest_doc_route = '/pods/{slug}';
29
30 /**
31 * {@inheritdoc}
32 *
33 * @since 2.8.0
34 */
35 public function READ_args() {
36 return [
37 'slug' => [
38 'type' => 'string',
39 'in' => 'path',
40 'description' => __( 'The Pod slug.', 'pods' ),
41 'required' => true,
42 ],
43 'include_fields' => [
44 'type' => 'boolean',
45 'description' => __( 'Whether to include fields (default: off).', 'pods' ),
46 'default' => false,
47 'cli_boolean' => true,
48 ],
49 'include_groups' => [
50 'type' => 'boolean',
51 'description' => __( 'Whether to include groups (default: off).', 'pods' ),
52 'default' => false,
53 'cli_boolean' => 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 'slug' => [
75 'type' => 'string',
76 'in' => 'path',
77 'description' => __( 'The Pod slug.', 'pods' ),
78 'required' => true,
79 ],
80 'new_name' => [
81 'type' => 'string',
82 'description' => __( 'The new name of the Pod.', 'pods' ),
83 ],
84 'label' => [
85 'type' => 'string',
86 'description' => __( 'The singular label of the Pod.', 'pods' ),
87 ],
88 'args' => [
89 'required' => false,
90 'description' => __( 'A list of additional options to save to the Pod.', 'pods' ),
91 'swagger_type' => 'array',
92 ],
93 ];
94 }
95
96 /**
97 * {@inheritdoc}
98 *
99 * @since 2.8.0
100 */
101 public function update( WP_REST_Request $request ) {
102 return $this->update_by_args( 'slug', 'name', $request );
103 }
104
105 /**
106 * {@inheritdoc}
107 *
108 * @since 2.8.0
109 */
110 public function DELETE_args() {
111 return [
112 'slug' => [
113 'type' => 'string',
114 'in' => 'path',
115 'description' => __( 'The Pod slug.', 'pods' ),
116 'required' => true,
117 ],
118 'delete_all' => [
119 'type' => 'boolean',
120 'description' => __( 'Whether to delete all content for Pod (default: off).', 'pods' ),
121 'default' => false,
122 'cli_boolean' => true,
123 ],
124 ];
125 }
126
127 /**
128 * {@inheritdoc}
129 *
130 * @since 2.8.0
131 */
132 public function delete( WP_REST_Request $request ) {
133 return $this->delete_by_args( 'slug', 'name', $request );
134 }
135 }
136