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