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 / Group_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
Group_Slug.php
154 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 Group_Slug extends Group {
13
14 /**
15 * {@inheritdoc}
16 *
17 * @since 2.8.0
18 */
19 public $route = '/pods/%1$s/groups/%2$s';
20
21 /**
22 * {@inheritdoc}
23 *
24 * @since 2.8.11
25 */
26 public $rest_route = '/pods/(?P<pod>[\w\_\-]+)/groups/(?P<slug>[\w\_\-]+)';
27
28 /**
29 * {@inheritdoc}
30 *
31 * @since 2.8.11
32 */
33 public $rest_doc_route = '/pods/{pod}/groups/{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 Group slug.', 'pods' ),
53 'required' => true,
54 ],
55 'include_fields' => [
56 'type' => 'boolean',
57 'description' => __( 'Whether to include fields (default: off).', 'pods' ),
58 'default' => false,
59 'cli_boolean' => true,
60 ],
61 ];
62 }
63
64 /**
65 * {@inheritdoc}
66 *
67 * @since 2.8.0
68 */
69 public function get( WP_REST_Request $request ) {
70 return $this->get_by_args( 'slug', 'name', $request );
71 }
72
73 /**
74 * {@inheritdoc}
75 *
76 * @since 2.8.0
77 */
78 public function EDIT_args() {
79 return [
80 'pod' => [
81 'type' => 'string',
82 'in' => 'path',
83 'description' => __( 'The Pod slug.', 'pods' ),
84 'required' => true,
85 'validate_callback' => [ $this->validator, 'is_pod_slug' ],
86 ],
87 'slug' => [
88 'type' => 'string',
89 'in' => 'path',
90 'description' => __( 'The Field slug.', 'pods' ),
91 'required' => true,
92 ],
93 'new_name' => [
94 'type' => 'string',
95 'description' => __( 'The new name of the Group.', 'pods' ),
96 ],
97 'label' => [
98 'type' => 'string',
99 'description' => __( 'The singular label of the Group.', 'pods' ),
100 ],
101 'type' => [
102 'type' => 'string',
103 'description' => __( 'The type of the Group.', 'pods' ),
104 ],
105 'args' => [
106 'required' => false,
107 'description' => __( 'A list of additional options to save to the Group.', 'pods' ),
108 'swagger_type' => 'array',
109 ],
110 ];
111 }
112
113 /**
114 * {@inheritdoc}
115 *
116 * @since 2.8.0
117 */
118 public function update( WP_REST_Request $request ) {
119 return $this->update_by_args( 'slug', 'name', $request );
120 }
121
122 /**
123 * {@inheritdoc}
124 *
125 * @since 2.8.0
126 */
127 public function DELETE_args() {
128 return [
129 'pod' => [
130 'type' => 'string',
131 'in' => 'path',
132 'description' => __( 'The Pod slug.', 'pods' ),
133 'required' => true,
134 'validate_callback' => [ $this->validator, 'is_pod_slug' ],
135 ],
136 'slug' => [
137 'type' => 'string',
138 'in' => 'path',
139 'description' => __( 'The Group slug.', 'pods' ),
140 'required' => true,
141 ],
142 ];
143 }
144
145 /**
146 * {@inheritdoc}
147 *
148 * @since 2.8.0
149 */
150 public function delete( WP_REST_Request $request ) {
151 return $this->delete_by_args( 'slug', 'name', $request );
152 }
153 }
154