Completed
Push — update/api-post-trash-status ( 8f5460 )
by
unknown
63:07 queued 51:34
created

json-endpoints.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * Endpoint class definitions. Only instantiations should be in this file
5
 *   file ordering matters
6
 */
7
8
$json_endpoints_dir = dirname( __FILE__ ) . '/json-endpoints/';
9
10
//abstract endpoints
11
require_once( $json_endpoints_dir . 'class.wpcom-json-api-post-endpoint.php' );
12
require_once( $json_endpoints_dir . 'class.wpcom-json-api-post-v1-1-endpoint.php' ); // v1.1
13
require_once( $json_endpoints_dir . 'class.wpcom-json-api-comment-endpoint.php' );
14
require_once( $json_endpoints_dir . 'class.wpcom-json-api-taxonomy-endpoint.php' );
15
16
17
// **********
18
// v1
19
// **********
20
21
require_once( $json_endpoints_dir . 'class.wpcom-json-api-delete-media-endpoint.php' );
22
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-comment-endpoint.php' );
23
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-media-endpoint.php' );
24
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-post-endpoint.php' );
25
require_once( $json_endpoints_dir . 'class.wpcom-json-api-render-endpoint.php' );
26
require_once( $json_endpoints_dir . 'class.wpcom-json-api-render-shortcode-endpoint.php' );
27
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-shortcodes-endpoint.php' );
28
require_once( $json_endpoints_dir . 'class.wpcom-json-api-render-embed-reversal-endpoint.php' );
29
require_once( $json_endpoints_dir . 'class.wpcom-json-api-render-embed-endpoint.php' );
30
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-embeds-endpoint.php' );
31
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-site-endpoint.php' );
32
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-taxonomies-endpoint.php' );
33
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-taxonomy-endpoint.php' );
34
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-term-endpoint.php' );
35
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-comments-endpoint.php' );
36
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-media-endpoint.php' );
37
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-post-types-endpoint.php' );
38
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-post-type-taxonomies-endpoint.php' );
39
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-posts-endpoint.php' );
40
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-roles-endpoint.php' );
41
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-terms-endpoint.php' );
42
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-users-endpoint.php' );
43
require_once( $json_endpoints_dir . 'class.wpcom-json-api-site-user-endpoint.php' );
44
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-comment-endpoint.php' );
45
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-media-endpoint.php' );
46
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-post-endpoint.php' );
47
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-taxonomy-endpoint.php' );
48
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-term-endpoint.php' );
49
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-user-endpoint.php' );
50
require_once( $json_endpoints_dir . 'class.wpcom-json-api-upload-media-endpoint.php' );
51
require_once( $json_endpoints_dir . 'class.wpcom-json-api-site-settings-endpoint.php' );
52
require_once( $json_endpoints_dir . 'class.wpcom-json-api-sharing-buttons-endpoint.php' );
53
54
// **********
55
// v1.1
56
// **********
57
58
// Media
59
require_once( $json_endpoints_dir . 'class.wpcom-json-api-delete-media-v1-1-endpoint.php' );
60
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-media-v1-1-endpoint.php' );
61
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-media-v1-1-endpoint.php' );
62
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-media-v1-1-endpoint.php' );
63
require_once( $json_endpoints_dir . 'class.wpcom-json-api-upload-media-v1-1-endpoint.php' );
64
65
// Posts
66
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-post-v1-1-endpoint.php' );
67
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-posts-v1-1-endpoint.php' );
68
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-post-v1-1-endpoint.php' );
69
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-autosave-v1-1-endpoint.php' );
70
require_once( $json_endpoints_dir . 'class.wpcom-json-api-autosave-post-v1-1-endpoint.php' );
71
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-post-counts-v1-1-endpoint.php' );
72
73
// Custom Menus
74
require_once( $json_endpoints_dir . 'class.wpcom-json-api-menus-v1-1-endpoint.php' );
75
76
// Users
77
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-invites-endpoint.php' );
78
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-invites-endpoint.php' );
79
80
// Custom CSS
81
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-customcss.php' );
82
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-customcss.php' );
83
84
// **********
85
// v1.2
86
// **********
87
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-post-v1-2-endpoint.php' );
88
89
// Jetpack Only Endpoints
90
$json_jetpack_endpoints_dir = dirname( __FILE__ ) . '/json-endpoints/jetpack/';
91
92
// This files instantiates the endpoints
93
require_once( $json_jetpack_endpoints_dir . 'json-api-jetpack-endpoints.php' );
94
95
/*
96
 * Endpoint instantiations
97
 */
98
99
new WPCOM_JSON_API_GET_Site_Endpoint( array(
100
	'description' => 'Get information about a site.',
101
	'group'	      => 'sites',
102
	'stat'        => 'sites:X',
103
	'allowed_if_flagged' => true,
104
	'method'      => 'GET',
105
	'path'        => '/sites/%s',
106
	'path_labels' => array(
107
		'$site' => '(int|string) Site ID or domain',
108
	),
109
110
	'query_parameters' => array(
111
		'context' => false,
112
	),
113
114
	'response_format' => WPCOM_JSON_API_GET_Site_Endpoint::$site_format,
115
116
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/',
117
) );
118
119
new WPCOM_JSON_API_GET_Post_Counts_V1_1_Endpoint( array(
120
	'description'   => 'Get number of posts in the post type groups by post status',
121
	'group'         => 'sites',
122
	'stat'          => 'sites:X:post-counts:X',
123
	'force'         => 'wpcom',
124
	'method'        => 'GET',
125
	'min_version'   => '1.1',
126
	'max_version'   => '1.2',
127
	'path'          => '/sites/%s/post-counts/%s',
128
	'path_labels'   => array(
129
		'$site'       => '(int|string) Site ID or domain',
130
		'$post_type'  => '(string) Post Type',
131
	),
132
133
	'query_parameters' => array(
134
		'context' => false,
135
		'author' => '(int) author ID',
136
	),
137
138
	'example_request' => 'https://public-api.wordpress.com/rest/v1.2/sites/en.blog.wordpress.com/post-counts/page',
139
140
	'response_format' => array(
141
		'counts' => array(
142
			'all' => '(array) Number of posts by any author in the post type grouped by post status',
143
			'mine' => '(array) Number of posts by the current user in the post type grouped by post status'
144
		)
145
	)
146
) );
147
148
149
new WPCOM_JSON_API_List_Post_Formats_Endpoint( array(
150
	'description' => 'Get a list of post formats supported by a site.',
151
	'group'       => '__do_not_document',
152
	'stat'        => 'sites:X:post-formats',
153
154
	'method'      => 'GET',
155
	'path'        => '/sites/%s/post-formats',
156
	'path_labels' => array(
157
		'$site' => '(int|string) Site ID or domain',
158
	),
159
160
	'query_parameters' => array(
161
		'context' => false,
162
	),
163
164
	'response_format' => array(
165
		'formats' => '(array) A list of supported post formats. id => label.',
166
	)
167
) );
168
169
new WPCOM_JSON_API_List_Page_Templates_Endpoint( array(
170
	'description' => 'Get a list of page templates supported by a site.',
171
	'group'       => 'sites',
172
	'stat'        => 'sites:X:post-templates',
173
174
	'method'      => 'GET',
175
	'path'        => '/sites/%s/page-templates',
176
	'path_labels' => array(
177
		'$site' => '(int|string) Site ID or domain',
178
	),
179
	'query_parameters' => array(
180
		'context' => false,
181
	),
182
	'response_format' => array(
183
		'templates' => '(array) A list of supported page templates. Contains label and file.',
184
	)
185
) );
186
187
new WPCOM_JSON_API_List_Post_Types_Endpoint( array (
188
	'description' => 'Get a list of post types available for a site.',
189
	'group'       => 'sites',
190
	'stat'        => 'sites:X:post-types',
191
192
	'method'      => 'GET',
193
	'path'        => '/sites/%s/post-types',
194
	'path_labels' => array(
195
		'$site' => '(int|string) Site ID or domain',
196
	),
197
198
	'query_parameters' => array(
199
		'api_queryable' => '(bool) If true, only queryable post types are returned',
200
	),
201
202
	'response_format' => array(
203
		'found'      => '(int) The number of post types found',
204
		'post_types' => '(array) A list of available post types',
205
	)
206
) );
207
208
new WPCOM_JSON_API_List_Post_Type_Taxonomies_Endpoint( array (
209
	'description' => 'Get a list of taxonomies associated with a post type.',
210
	'group'       => 'taxonomy',
211
	'stat'        => 'sites:X:post-types:X:taxonomies',
212
	'method'      => 'GET',
213
	'path'        => '/sites/%s/post-types/%s/taxonomies',
214
	'path_labels' => array(
215
		'$site'      => '(int|string) Site ID or domain',
216
		'$post_type' => '(string) Post type',
217
	),
218
	'response_format' => array(
219
		'found'      => '(int) The number of taxonomies found',
220
		'taxonomies' => '(array:taxonomy) A list of available taxonomies',
221
	)
222
) );
223
224
/*
225
 * Shortcode endpoints
226
 */
227
228
new WPCOM_JSON_API_List_Shortcodes_Endpoint( array(
229
	'description' => "Get a list of shortcodes available on a site. Note: The current user must have publishing access.",
230
	'group'       => 'sites',
231
	'stat'        => 'shortcodes',
232
	'method'      => 'GET',
233
	'path'        => '/sites/%s/shortcodes',
234
	'path_labels' => array(
235
		'$site'    => '(int|string) Site ID or domain',
236
	),
237
	'response_format' => array(
238
		'shortcodes' => '(array) A list of supported shortcodes by their handle.',
239
	),
240
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/shortcodes',
241
	'example_request_data' => array(
242
		'headers' => array(
243
			'authorization' => 'Bearer YOUR_API_TOKEN'
244
		),
245
	)
246
) );
247
248
new WPCOM_JSON_API_Render_Shortcode_Endpoint( array(
249
	'description' => "Get a rendered shortcode for a site. Note: The current user must have publishing access.",
250
	'group'       => 'sites',
251
	'stat'        => 'shortcodes:render',
252
	'method'      => 'GET',
253
	'path'        => '/sites/%s/shortcodes/render',
254
	'path_labels' => array(
255
		'$site'    => '(int|string) Site ID or domain',
256
	),
257
	'query_parameters' => array(
258
		'shortcode'     => '(string) The query-string encoded shortcode string to render. Required. Only accepts one at a time.',
259
	),
260
	'response_format' => array(
261
		'shortcode' => '(string) The shortcode that was passed in for rendering.',
262
		'result'    => '(html) The rendered HTML result of the shortcode.',
263
		'scripts'   => '(array) An array of JavaScript files needed to render the shortcode. Returned in the format of <code>{ "script-slug" : { "src": "http://example.com/file.js", "extra" : "" } }</code> where extra contains any neccessary extra JS for initializing the source file and src contains the script to load. Omitted if no scripts are neccessary.',
264
		'styles'    => '(array) An array of CSS files needed to render the shortcode. Returned in the format of <code>{ "style-slug" : { "src": "http://example.com/file.css", "media" : "all" } }</code>. Omitted if no styles are neccessary.',
265
	),
266
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/shortcodes/render?shortcode=%5Bgallery%20ids%3D%22729%2C732%2C731%2C720%22%5D',
267
	'example_request_data' => array(
268
		'headers' => array(
269
			'authorization' => 'Bearer YOUR_API_TOKEN'
270
		),
271
	)
272
) );
273
274
/*
275
 * embed endpoints
276
 */
277
new WPCOM_JSON_API_List_Embeds_Endpoint( array(
278
	'description' => "Get a list of embeds available on a site. Note: The current user must have publishing access.",
279
	'group'       => 'sites',
280
	'stat'        => 'embeds',
281
	'method'      => 'GET',
282
	'path'        => '/sites/%s/embeds',
283
	'path_labels' => array(
284
		'$site'    => '(int|string) Site ID or domain',
285
	),
286
	'response_format' => array(
287
		'embeds' => '(array) A list of supported embeds by their regex pattern.',
288
	),
289
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/embeds',
290
	'example_request_data' => array(
291
		'headers' => array(
292
			'authorization' => 'Bearer YOUR_API_TOKEN'
293
		),
294
	)
295
) );
296
297
new WPCOM_JSON_API_Render_Embed_Endpoint( array(
298
	'description' => "Get a rendered embed for a site. Note: The current user must have publishing access.",
299
	'group'       => 'sites',
300
	'stat'        => 'embeds:render',
301
	'method'      => 'GET',
302
	'path'        => '/sites/%s/embeds/render',
303
	'path_labels' => array(
304
		'$site'    => '(int|string) Site ID or domain',
305
	),
306
	'query_parameters' => array(
307
		'embed_url'     => '(string) The query-string encoded embed URL to render. Required. Only accepts one at a time.',
308
	),
309
	'response_format' => array(
310
		'embed_url' => '(string) The embed_url that was passed in for rendering.',
311
		'result'    => '(html) The rendered HTML result of the embed.',
312
	),
313
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/apiexamples.wordpress.com/embeds/render?embed_url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DSQEQr7c0-dw',
314
	'example_request_data' => array(
315
		'headers' => array(
316
			'authorization' => 'Bearer YOUR_API_TOKEN'
317
		),
318
	)
319
) );
320
321
new WPCOM_JSON_API_Render_Embed_Reversal_Endpoint( array(
322
	'description' => "Determines if the given embed code can be reversed into a single line embed or a shortcode, and if so returns the embed or shortcode. Note: The current user must have publishing access.",
323
	//'group'       => 'sites',
324
	'group'       => '__do_not_document',
325
	'stat'        => 'embeds:reversal',
326
	'method'      => 'POST',
327
	'path'        => '/sites/%s/embeds/reversal',
328
	'path_labels' => array(
329
		'$site'    => '(int|string) Site ID or domain',
330
	),
331
	'request_format' => array(
332
		'maybe_embed' => '(string) The embed code to reverse. Required. Only accepts one at a time.',
333
	),
334
	'response_format' => array(
335
		'maybe_embed' => '(string) The original embed code that was passed in for rendering.',
336
		'reversal_type' => '(string) The type of reversal. Either an embed or a shortcode.',
337
		'render_result' => '(html) The rendered HTML result of the embed or shortcode.',
338
		'result' => '(string) The reversed content. Either a single line embed or a shortcode.',
339
		'scripts'   => '(array) An array of JavaScript files needed to render the embed or shortcode. Returned in the format of <code>{ "script-slug" : { "src": "http://example.com/file.js", "extra" : "" } }</code> where extra contains any neccessary extra JS for initializing the source file and src contains the script to load. Omitted if no scripts are neccessary.',
340
		'styles'    => '(array) An array of CSS files needed to render the embed or shortcode. Returned in the format of <code>{ "style-slug" : { "src": "http://example.com/file.css", "media" : "all" } }</code>. Omitted if no styles are neccessary.',
341
	),
342
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/shortcode-reversals/render/',
343
	'example_request_data' => array(
344
		'headers' => array(
345
			'authorization' => 'Bearer YOUR_API_TOKEN'
346
		),
347
348
		'body' => array(
349
			'maybe_embed' => '<iframe width="480" height="302" src="http://www.ustream.tv/embed/recorded/26370522/highlight/299667?v=3&amp;wmode=direct" scrolling="no" frameborder="0"></iframe>',
350
		)
351
	),
352
) );
353
354
355
/*
356
 * Post endpoints
357
 */
358
new WPCOM_JSON_API_List_Posts_Endpoint( array(
359
	'description' => 'Get a list of matching posts.',
360
	'new_version' => '1.1',
361
	'max_version' => '1',
362
	'group'       => 'posts',
363
	'stat'        => 'posts',
364
365
	'method'      => 'GET',
366
	'path'        => '/sites/%s/posts/',
367
	'path_labels' => array(
368
		'$site' => '(int|string) Site ID or domain',
369
	),
370
371
	'query_parameters' => array(
372
		'number'   => '(int=20) The number of posts to return. Limit: 100.',
373
		'offset'   => '(int=0) 0-indexed offset.',
374
		'page'     => '(int) Return the Nth 1-indexed page of posts. Takes precedence over the <code>offset</code> parameter.',
375
		'order'    => array(
376
			'DESC' => 'Return posts in descending order. For dates, that means newest to oldest.',
377
			'ASC'  => 'Return posts in ascending order. For dates, that means oldest to newest.',
378
		),
379
		'order_by' => array(
380
			'date'          => 'Order by the created time of each post.',
381
			'modified'      => 'Order by the modified time of each post.',
382
			'title'         => "Order lexicographically by the posts' titles.",
383
			'comment_count' => 'Order by the number of comments for each post.',
384
			'ID'            => 'Order by post ID.',
385
		),
386
		'after'    => '(ISO 8601 datetime) Return posts dated on or after the specified datetime.',
387
		'before'   => '(ISO 8601 datetime) Return posts dated on or before the specified datetime.',
388
		'tag'      => '(string) Specify the tag name or slug.',
389
		'category' => '(string) Specify the category name or slug.',
390
		'type'     => "(string) Specify the post type. Defaults to 'post', use 'any' to query for both posts and pages. Post types besides post and page need to be whitelisted using the <code>rest_api_allowed_post_types</code> filter.",
391
		'parent_id' => '(int) Returns only posts which are children of the specified post. Applies only to hierarchical post types.',
392
		'exclude'  => '(array:int|int) Excludes the specified post ID(s) from the response',
393
		'exclude_tree' => '(int) Excludes the specified post and all of its descendants from the response. Applies only to hierarchical post types.',
394
		'status'   => array(
395
			'publish' => 'Return only published posts.',
396
			'private' => 'Return only private posts.',
397
			'draft'   => 'Return only draft posts.',
398
			'pending' => 'Return only posts pending editorial approval.',
399
			'future'  => 'Return only posts scheduled for future publishing.',
400
			'trash'   => 'Return only posts in the trash.',
401
			'any'     => 'Return all posts regardless of status.',
402
		),
403
		'sticky'    => array(
404
			'false'   => 'Post is not marked as sticky.',
405
			'true'    => 'Stick the post to the front page.',
406
		),
407
		'author'   => "(int) Author's user ID",
408
		'search'   => '(string) Search query',
409
		'meta_key'   => '(string) Metadata key that the post should contain',
410
		'meta_value'   => '(string) Metadata value that the post should contain. Will only be applied if a `meta_key` is also given',
411
	),
412
413
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/posts/?number=5'
414
) );
415
416
new WPCOM_JSON_API_List_Posts_v1_1_Endpoint( array(
417
	'description' => 'Get a list of matching posts.',
418
	'min_version' => '1.1',
419
	'max_version' => '1.1',
420
421
	'group'       => 'posts',
422
	'stat'        => 'posts',
423
424
	'method'      => 'GET',
425
	'path'        => '/sites/%s/posts/',
426
	'path_labels' => array(
427
		'$site' => '(int|string) Site ID or domain',
428
	),
429
430
	'query_parameters' => array(
431
		'number'   => '(int=20) The number of posts to return. Limit: 100.',
432
		'offset'   => '(int=0) 0-indexed offset.',
433
		'page'     => '(int) Return the Nth 1-indexed page of posts. Takes precedence over the <code>offset</code> parameter.',
434
		'page_handle' => '(string) A page handle, returned from a previous API call as a <code>meta.next_page</code> property. This is the most efficient way to fetch the next page of results.',
435
		'order'    => array(
436
			'DESC' => 'Return posts in descending order. For dates, that means newest to oldest.',
437
			'ASC'  => 'Return posts in ascending order. For dates, that means oldest to newest.',
438
		),
439
		'order_by' => array(
440
			'date'          => 'Order by the created time of each post.',
441
			'modified'      => 'Order by the modified time of each post.',
442
			'title'         => "Order lexicographically by the posts' titles.",
443
			'comment_count' => 'Order by the number of comments for each post.',
444
			'ID'            => 'Order by post ID.',
445
		),
446
		'after'    => '(ISO 8601 datetime) Return posts dated after the specified datetime.',
447
		'before'   => '(ISO 8601 datetime) Return posts dated before the specified datetime.',
448
		'modified_after'    => '(ISO 8601 datetime) Return posts modified after the specified datetime.',
449
		'modified_before'   => '(ISO 8601 datetime) Return posts modified before the specified datetime.',
450
		'tag'      => '(string) Specify the tag name or slug.',
451
		'category' => '(string) Specify the category name or slug.',
452
		'type'     => "(string) Specify the post type. Defaults to 'post', use 'any' to query for both posts and pages. Post types besides post and page need to be whitelisted using the <code>rest_api_allowed_post_types</code> filter.",
453
		'parent_id' => '(int) Returns only posts which are children of the specified post. Applies only to hierarchical post types.',
454
		'exclude'  => '(array:int|int) Excludes the specified post ID(s) from the response',
455
		'exclude_tree' => '(int) Excludes the specified post and all of its descendants from the response. Applies only to hierarchical post types.',
456
		'status'   => '(string) Comma-separated list of statuses for which to query, including any of: "publish", "private", "draft", "pending", "future", and "trash", or simply "any". Defaults to "publish"',
457
		'sticky'    => array(
458
			'include'   => 'Sticky posts are not excluded from the list.',
459
			'exclude'   => 'Sticky posts are excluded from the list.',
460
			'require'   => 'Only include sticky posts',
461
		),
462
		'author'   => "(int) Author's user ID",
463
		'search'   => '(string) Search query',
464
		'meta_key'   => '(string) Metadata key that the post should contain',
465
		'meta_value'   => '(string) Metadata value that the post should contain. Will only be applied if a `meta_key` is also given',
466
	),
467
468
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/en.blog.wordpress.com/posts/?number=2'
469
) );
470
471
new WPCOM_JSON_API_Get_Post_Endpoint( array(
472
	'description' => 'Get a single post (by ID).',
473
	'group'       => 'posts',
474
	'stat'        => 'posts:1',
475
	'new_version' => '1.1',
476
	'max_version' => '1',
477
	'method'      => 'GET',
478
	'path'        => '/sites/%s/posts/%d',
479
	'path_labels' => array(
480
		'$site'    => '(int|string) Site ID or domain',
481
		'$post_ID' => '(int) The post ID',
482
	),
483
484
	'example_request'  => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/posts/7'
485
) );
486
487
new WPCOM_JSON_API_Get_Post_v1_1_Endpoint( array(
488
	'description' => 'Get a single post (by ID).',
489
	'min_version' => '1.1',
490
	'max_version' => '1.1',
491
	'group'       => 'posts',
492
	'stat'        => 'posts:1',
493
	'method'      => 'GET',
494
	'path'        => '/sites/%s/posts/%d',
495
	'path_labels' => array(
496
		'$site'    => '(int|string) Site ID or domain',
497
		'$post_ID' => '(int) The post ID',
498
	),
499
	'example_request'  => 'https://public-api.wordpress.com/rest/v1.1/sites/en.blog.wordpress.com/posts/7'
500
) );
501
502
new WPCOM_JSON_API_Get_Post_Endpoint( array(
503
	'description' => 'Get a single post (by name)',
504
	'group'       => '__do_not_document',
505
	'stat'        => 'posts:name',
506
	'method'      => 'GET',
507
	'path'        => '/sites/%s/posts/name:%s',
508
	'path_labels' => array(
509
		'$site'      => '(int|string) Site ID or domain',
510
		'$post_name' => '(string) The post name (a.k.a. slug)',
511
	),
512
513
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/posts/name:blogging-and-stuff?pretty=1',
514
) );
515
516
new WPCOM_JSON_API_Get_Post_Endpoint( array(
517
	'description' => 'Get a single post (by slug).',
518
	'group'       => 'posts',
519
	'stat'        => 'posts:slug',
520
	'new_version' => '1.1',
521
	'max_version' => '1',
522
	'method'      => 'GET',
523
	'path'        => '/sites/%s/posts/slug:%s',
524
	'path_labels' => array(
525
		'$site'      => '(int|string) Site ID or domain',
526
		'$post_slug' => '(string) The post slug (a.k.a. sanitized name)',
527
	),
528
529
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/posts/slug:blogging-and-stuff',
530
) );
531
532
new WPCOM_JSON_API_Get_Post_v1_1_Endpoint( array(
533
	'description' => 'Get a single post (by slug).',
534
	'min_version' => '1.1',
535
	'max_version' => '1.1',
536
	'group'       => 'posts',
537
	'stat'        => 'posts:slug',
538
	'method'      => 'GET',
539
	'path'        => '/sites/%s/posts/slug:%s',
540
	'path_labels' => array(
541
		'$site'      => '(int|string) Site ID or domain',
542
		'$post_slug' => '(string) The post slug (a.k.a. sanitized name)',
543
	),
544
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/en.blog.wordpress.com/posts/slug:blogging-and-stuff',
545
) );
546
547
new WPCOM_JSON_API_Update_Post_Endpoint( array(
548
	'description' => 'Create a post.',
549
	'group'       => 'posts',
550
	'stat'        => 'posts:new',
551
	'new_version' => '1.2',
552
	'max_version' => '1',
553
	'method'      => 'POST',
554
	'path'        => '/sites/%s/posts/new',
555
	'path_labels' => array(
556
		'$site' => '(int|string) Site ID or domain',
557
	),
558
559
	'request_format' => array(
560
		// explicitly document all input
561
		'date'      => "(ISO 8601 datetime) The post's creation time.",
562
		'title'     => '(HTML) The post title.',
563
		'content'   => '(HTML) The post content.',
564
		'excerpt'   => '(HTML) An optional post excerpt.',
565
		'slug'      => '(string) The name (slug) for the post, used in URLs.',
566
		'author'    => '(string) The username or ID for the user to assign the post to.',
567
		'publicize' => '(array|bool) True or false if the post be publicized to external services. An array of services if we only want to publicize to a select few. Defaults to true.',
568
		'publicize_message' => '(string) Custom message to be publicized to external services.',
569
		'status'    => array(
570
			'publish' => 'Publish the post.',
571
			'private' => 'Privately publish the post.',
572
			'draft'   => 'Save the post as a draft.',
573
			'pending' => 'Mark the post as pending editorial approval.',
574
			'auto-draft' => 'Save a placeholder for a newly created post, with no content.',
575
		),
576
		'sticky'    => array(
577
			'false'   => 'Post is not marked as sticky.',
578
			'true'    => 'Stick the post to the front page.',
579
		),
580
		'password'  => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.',
581
		'parent'    => "(int) The post ID of the new post's parent.",
582
		'type'      => "(string) The post type. Defaults to 'post'. Post types besides post and page need to be whitelisted using the <code>rest_api_allowed_post_types</code> filter.",
583
		'categories' => "(array|string) Comma-separated list or array of categories (name or id)",
584
		'tags'       => "(array|string) Comma-separated list or array of tags (name or id)",
585
		'format'     => array_merge( array( 'default' => 'Use default post format' ), get_post_format_strings() ),
586
		'featured_image' => "(string) The post ID of an existing attachment to set as the featured image. Pass an empty string to delete the existing image.",
587
		'media'      => "(media) An array of files to attach to the post. To upload media, the entire request should be multipart/form-data encoded. Multiple media items will be displayed in a gallery. Accepts  jpg, jpeg, png, gif, pdf, doc, ppt, odt, pptx, docx, pps, ppsx, xls, xlsx, key. Audio and Video may also be available. See <code>allowed_file_types</code> in the options response of the site endpoint. <br /><br /><strong>Example</strong>:<br />" .
588
		 				"<code>curl \<br />--form 'title=Image' \<br />--form 'media[]=@/path/to/file.jpg' \<br />-H 'Authorization: BEARER your-token' \<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>",
589
		'media_urls' => "(array) An array of URLs for images to attach to a post. Sideloads the media in for a post.",
590
		'metadata'      => "(array) Array of metadata objects containing the following properties: `key` (metadata key), `id` (meta ID), `previous_value` (if set, the action will only occur for the provided previous value), `value` (the new value to set the meta to), `operation` (the operation to perform: `update` or `add`; defaults to `update`). All unprotected meta keys are available by default for read requests. Both unprotected and protected meta keys are avaiable for authenticated requests with proper capabilities. Protected meta keys can be made available with the <code>rest_api_allowed_public_metadata</code> filter.",
591
		'comments_open' => "(bool) Should the post be open to comments? Defaults to the blog's preference.",
592
		'pings_open'    => "(bool) Should the post be open to comments? Defaults to the blog's preference.",
593
		'likes_enabled' => "(bool) Should the post be open to likes? Defaults to the blog's preference.",
594
		'sharing_enabled' => "(bool) Should sharing buttons show on this post? Defaults to true.",
595
		'menu_order'    => "(int) (Pages Only) the order pages should appear in. Use 0 to maintain alphabetical order.",
596
	),
597
598
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/posts/new/',
599
600
	'example_request_data' => array(
601
		'headers' => array(
602
			'authorization' => 'Bearer YOUR_API_TOKEN'
603
		),
604
605
		'body' => array(
606
			'title'      => 'Hello World',
607
			'content'    => 'Hello. I am a test post. I was created by the API',
608
			'tags'       => 'tests',
609
			'categories' => 'API'
610
		)
611
	)
612
) );
613
614
new WPCOM_JSON_API_Update_Post_v1_1_Endpoint( array(
615
	'description' => 'Create a post.',
616
	'group'       => 'posts',
617
	'stat'        => 'posts:new',
618
	'new_version' => '1.2',
619
	'min_version' => '1.1',
620
	'max_version' => '1.1',
621
	'method'      => 'POST',
622
	'path'        => '/sites/%s/posts/new',
623
	'path_labels' => array(
624
		'$site' => '(int|string) Site ID or domain',
625
	),
626
627
	'request_format' => array(
628
		// explicitly document all input
629
		'date'      => "(ISO 8601 datetime) The post's creation time.",
630
		'title'     => '(HTML) The post title.',
631
		'content'   => '(HTML) The post content.',
632
		'excerpt'   => '(HTML) An optional post excerpt.',
633
		'slug'      => '(string) The name (slug) for the post, used in URLs.',
634
		'author'    => '(string) The username or ID for the user to assign the post to.',
635
		'publicize' => '(array|bool) True or false if the post be publicized to external services. An array of services if we only want to publicize to a select few. Defaults to true.',
636
		'publicize_message' => '(string) Custom message to be publicized to external services.',
637
		'status'    => array(
638
			'publish' => 'Publish the post.',
639
			'private' => 'Privately publish the post.',
640
			'draft'   => 'Save the post as a draft.',
641
			'pending' => 'Mark the post as pending editorial approval.',
642
			'future'  => 'Schedule the post (alias for publish; you must also set a future date).',
643
			'auto-draft' => 'Save a placeholder for a newly created post, with no content.',
644
		),
645
		'sticky'    => array(
646
			'false'   => 'Post is not marked as sticky.',
647
			'true'    => 'Stick the post to the front page.',
648
		),
649
		'password'  => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.',
650
		'parent'    => "(int) The post ID of the new post's parent.",
651
		'type'      => "(string) The post type. Defaults to 'post'. Post types besides post and page need to be whitelisted using the <code>rest_api_allowed_post_types</code> filter.",
652
		'terms'      => '(object) Mapping of taxonomy to comma-separated list or array of terms (name or id)',
653
		'categories' => "(array|string) Comma-separated list or array of categories (name or id)",
654
		'tags'       => "(array|string) Comma-separated list or array of tags (name or id)",
655
		'format'     => array_merge( array( 'default' => 'Use default post format' ), get_post_format_strings() ),
656
		'featured_image' => "(string) The post ID of an existing attachment to set as the featured image. Pass an empty string to delete the existing image.",
657
		'media'      => "(media) An array of files to attach to the post. To upload media, the entire request should be multipart/form-data encoded. Multiple media items will be displayed in a gallery. Accepts  jpg, jpeg, png, gif, pdf, doc, ppt, odt, pptx, docx, pps, ppsx, xls, xlsx, key. Audio and Video may also be available. See <code>allowed_file_types</code> in the options response of the site endpoint. Errors produced by media uploads, if any, will be in `media_errors` in the response. <br /><br /><strong>Example</strong>:<br />" .
658
		 				"<code>curl \<br />--form 'title=Image Post' \<br />--form 'media[0]=@/path/to/file.jpg' \<br />--form 'media_attrs[0][caption]=My Great Photo' \<br />-H 'Authorization: BEARER your-token' \<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>",
659
		'media_urls' => "(array) An array of URLs for images to attach to a post. Sideloads the media in for a post. Errors produced by media sideloading, if any, will be in `media_errors` in the response.",
660
		'media_attrs' => "(array) An array of attributes (`title`, `description` and `caption`) are supported to assign to the media uploaded via the `media` or `media_urls` properties. You must use a numeric index for the keys of `media_attrs` which follow the same sequence as `media` and `media_urls`. <br /><br /><strong>Example</strong>:<br />" .
661
		                 "<code>curl \<br />--form 'title=Gallery Post' \<br />--form 'media[]=@/path/to/file1.jpg' \<br />--form 'media_urls[]=http://exapmple.com/file2.jpg' \<br /> \<br />--form 'media_attrs[0][caption]=This will be the caption for file1.jpg' \<br />--form 'media_attrs[1][title]=This will be the title for file2.jpg' \<br />-H 'Authorization: BEARER your-token' \<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>",
662
		'metadata'      => "(array) Array of metadata objects containing the following properties: `key` (metadata key), `id` (meta ID), `previous_value` (if set, the action will only occur for the provided previous value), `value` (the new value to set the meta to), `operation` (the operation to perform: `update` or `add`; defaults to `update`). All unprotected meta keys are available by default for read requests. Both unprotected and protected meta keys are avaiable for authenticated requests with proper capabilities. Protected meta keys can be made available with the <code>rest_api_allowed_public_metadata</code> filter.",
663
		'discussion'    => '(object) A hash containing one or more of the following boolean values, which default to the blog\'s discussion preferences: `comments_open`, `pings_open`',
664
		'likes_enabled' => "(bool) Should the post be open to likes? Defaults to the blog's preference.",
665
		'sharing_enabled' => "(bool) Should sharing buttons show on this post? Defaults to true.",
666
		'menu_order'    => "(int) (Pages Only) the order pages should appear in. Use 0 to maintain alphabetical order.",
667
		'page_template' => '(string) (Pages Only) The page template this page should use.',
668
	),
669
670
	'example_request'      => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/new/',
671
672
	'example_request_data' => array(
673
		'headers' => array(
674
			'authorization' => 'Bearer YOUR_API_TOKEN'
675
		),
676
677
		'body' => array(
678
			'title'      => 'Hello World',
679
			'content'    => 'Hello. I am a test post. I was created by the API',
680
			'tags'       => 'tests',
681
			'categories' => 'API'
682
		)
683
	)
684
) );
685
686
new WPCOM_JSON_API_Update_Post_v1_2_Endpoint( array(
687
	'description' => 'Create a post.',
688
	'group'       => 'posts',
689
	'stat'        => 'posts:new',
690
	'min_version' => '1.2',
691
	'max_version' => '1.2',
692
	'method'      => 'POST',
693
	'path'        => '/sites/%s/posts/new',
694
	'path_labels' => array(
695
		'$site' => '(int|string) Site ID or domain',
696
	),
697
698
	'request_format' => array(
699
		// explicitly document all input
700
		'date'      => "(ISO 8601 datetime) The post's creation time.",
701
		'title'     => '(HTML) The post title.',
702
		'content'   => '(HTML) The post content.',
703
		'excerpt'   => '(HTML) An optional post excerpt.',
704
		'slug'      => '(string) The name (slug) for the post, used in URLs.',
705
		'author'    => '(string) The username or ID for the user to assign the post to.',
706
		'publicize' => '(array|bool) True or false if the post be publicized to external services. An array of services if we only want to publicize to a select few. Defaults to true.',
707
		'publicize_message' => '(string) Custom message to be publicized to external services.',
708
		'status'    => array(
709
			'publish' => 'Publish the post.',
710
			'private' => 'Privately publish the post.',
711
			'draft'   => 'Save the post as a draft.',
712
			'pending' => 'Mark the post as pending editorial approval.',
713
			'future'  => 'Schedule the post (alias for publish; you must also set a future date).',
714
			'auto-draft' => 'Save a placeholder for a newly created post, with no content.',
715
		),
716
		'sticky'    => array(
717
			'false'   => 'Post is not marked as sticky.',
718
			'true'    => 'Stick the post to the front page.',
719
		),
720
		'password'  => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.',
721
		'parent'    => "(int) The post ID of the new post's parent.",
722
		'type'      => "(string) The post type. Defaults to 'post'. Post types besides post and page need to be whitelisted using the <code>rest_api_allowed_post_types</code> filter.",
723
		'terms'      => '(object) Mapping of taxonomy to comma-separated list or array of term names',
724
		'categories' => "(array|string) Comma-separated list or array of category names",
725
		'tags'       => "(array|string) Comma-separated list or array of tag names",
726
		'terms_by_id'      => '(object) Mapping of taxonomy to comma-separated list or array of term IDs',
727
		'categories_by_id' => "(array|string) Comma-separated list or array of category IDs",
728
		'tags_by_id'       => "(array|string) Comma-separated list or array of tag IDs",
729
		'format'     => array_merge( array( 'default' => 'Use default post format' ), get_post_format_strings() ),
730
		'featured_image' => "(string) The post ID of an existing attachment to set as the featured image. Pass an empty string to delete the existing image.",
731
		'media'      => "(media) An array of files to attach to the post. To upload media, the entire request should be multipart/form-data encoded. Multiple media items will be displayed in a gallery. Accepts  jpg, jpeg, png, gif, pdf, doc, ppt, odt, pptx, docx, pps, ppsx, xls, xlsx, key. Audio and Video may also be available. See <code>allowed_file_types</code> in the options response of the site endpoint. Errors produced by media uploads, if any, will be in `media_errors` in the response. <br /><br /><strong>Example</strong>:<br />" .
732
		 				"<code>curl \<br />--form 'title=Image Post' \<br />--form 'media[0]=@/path/to/file.jpg' \<br />--form 'media_attrs[0][caption]=My Great Photo' \<br />-H 'Authorization: BEARER your-token' \<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>",
733
		'media_urls' => "(array) An array of URLs for images to attach to a post. Sideloads the media in for a post. Errors produced by media sideloading, if any, will be in `media_errors` in the response.",
734
		'media_attrs' => "(array) An array of attributes (`title`, `description` and `caption`) are supported to assign to the media uploaded via the `media` or `media_urls` properties. You must use a numeric index for the keys of `media_attrs` which follow the same sequence as `media` and `media_urls`. <br /><br /><strong>Example</strong>:<br />" .
735
		                 "<code>curl \<br />--form 'title=Gallery Post' \<br />--form 'media[]=@/path/to/file1.jpg' \<br />--form 'media_urls[]=http://exapmple.com/file2.jpg' \<br /> \<br />--form 'media_attrs[0][caption]=This will be the caption for file1.jpg' \<br />--form 'media_attrs[1][title]=This will be the title for file2.jpg' \<br />-H 'Authorization: BEARER your-token' \<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>",
736
		'metadata'      => "(array) Array of metadata objects containing the following properties: `key` (metadata key), `id` (meta ID), `previous_value` (if set, the action will only occur for the provided previous value), `value` (the new value to set the meta to), `operation` (the operation to perform: `update` or `add`; defaults to `update`). All unprotected meta keys are available by default for read requests. Both unprotected and protected meta keys are avaiable for authenticated requests with proper capabilities. Protected meta keys can be made available with the <code>rest_api_allowed_public_metadata</code> filter.",
737
		'discussion'    => '(object) A hash containing one or more of the following boolean values, which default to the blog\'s discussion preferences: `comments_open`, `pings_open`',
738
		'likes_enabled' => "(bool) Should the post be open to likes? Defaults to the blog's preference.",
739
		'sharing_enabled' => "(bool) Should sharing buttons show on this post? Defaults to true.",
740
		'menu_order'    => "(int) (Pages Only) the order pages should appear in. Use 0 to maintain alphabetical order.",
741
		'page_template' => '(string) (Pages Only) The page template this page should use.',
742
	),
743
744
	'example_request'      => 'https://public-api.wordpress.com/rest/v1.2/sites/82974409/posts/new/',
745
746
	'example_request_data' => array(
747
		'headers' => array(
748
			'authorization' => 'Bearer YOUR_API_TOKEN'
749
		),
750
751
		'body' => array(
752
			'title'      => 'Hello World',
753
			'content'    => 'Hello. I am a test post. I was created by the API',
754
			'tags'       => 'tests',
755
			'categories' => 'API'
756
		)
757
	)
758
) );
759
760
new WPCOM_JSON_API_Update_Post_Endpoint( array(
761
	'description' => 'Edit a post.',
762
	'group'       => 'posts',
763
	'stat'        => 'posts:1:POST',
764
	'new_version' => '1.2',
765
	'max_version' => '1',
766
	'method'      => 'POST',
767
	'path'        => '/sites/%s/posts/%d',
768
	'path_labels' => array(
769
		'$site'    => '(int|string) Site ID or domain',
770
		'$post_ID' => '(int) The post ID',
771
	),
772
773
	'request_format' => array(
774
		'date'      => "(ISO 8601 datetime) The post's creation time.",
775
		'title'     => '(HTML) The post title.',
776
		'content'   => '(HTML) The post content.',
777
		'excerpt'   => '(HTML) An optional post excerpt.',
778
		'slug'      => '(string) The name (slug) for the post, used in URLs.',
779
		'author'    => '(string) The username or ID for the user to assign the post to.',
780
		'publicize' => '(array|bool) True or false if the post be publicized to external services. An array of services if we only want to publicize to a select few. Defaults to true.',
781
		'publicize_message' => '(string) Custom message to be publicized to external services.',
782
		'status'    => array(
783
			'publish' => 'Publish the post.',
784
			'private' => 'Privately publish the post.',
785
			'draft'   => 'Save the post as a draft.',
786
			'pending' => 'Mark the post as pending editorial approval.',
787
		),
788
		'sticky'    => array(
789
			'false'   => 'Post is not marked as sticky.',
790
			'true'    => 'Stick the post to the front page.',
791
		),
792
		'password'   => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.',
793
		'parent'     => "(int) The post ID of the new post's parent.",
794
		'categories' => "(array|string) Comma-separated list or array of categories (name or id)",
795
		'tags'       => "(array|string) Comma-separated list or array of tags (name or id)",
796
		'format'     => array_merge( array( 'default' => 'Use default post format' ), get_post_format_strings() ),
797
		'comments_open' => '(bool) Should the post be open to comments?',
798
		'pings_open'    => '(bool) Should the post be open to comments?',
799
		'likes_enabled' => "(bool) Should the post be open to likes?",
800
		'menu_order'    => "(int) (Pages Only) the order pages should appear in. Use 0 to maintain alphabetical order.",
801
		'sharing_enabled' => "(bool) Should sharing buttons show on this post?",
802
		'featured_image' => "(string) The post ID of an existing attachment to set as the featured image. Pass an empty string to delete the existing image.",
803
		'media'      => "(media) An array of files to attach to the post. To upload media, the entire request should be multipart/form-data encoded. Multiple media items will be displayed in a gallery. Accepts  jpg, jpeg, png, gif, pdf, doc, ppt, odt, pptx, docx, pps, ppsx, xls, xlsx, key. Audio and Video may also be available. See <code>allowed_file_types</code> in the options resposne of the site endpoint. <br /><br /><strong>Example</strong>:<br />" .
804
		 				"<code>curl \<br />--form 'title=Image' \<br />--form 'media[]=@/path/to/file.jpg' \<br />-H 'Authorization: BEARER your-token' \<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>",
805
		'media_urls' => "(array) An array of URLs for images to attach to a post. Sideloads the media in for a post.",
806
		'metadata'      => "(array) Array of metadata objects containing the following properties: `key` (metadata key), `id` (meta ID), `previous_value` (if set, the action will only occur for the provided previous value), `value` (the new value to set the meta to), `operation` (the operation to perform: `update` or `add`; defaults to `update`). All unprotected meta keys are available by default for read requests. Both unprotected and protected meta keys are available for authenticated requests with proper capabilities. Protected meta keys can be made available with the <code>rest_api_allowed_public_metadata</code> filter.",
807
	),
808
809
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/posts/881',
810
811
	'example_request_data' => array(
812
		'headers' => array(
813
			'authorization' => 'Bearer YOUR_API_TOKEN'
814
		),
815
816
		'body' => array(
817
			'title'      => 'Hello World (Again)',
818
			'content'    => 'Hello. I am an edited post. I was edited by the API',
819
			'tags'       => 'tests',
820
			'categories' => 'API'
821
		)
822
	)
823
) );
824
825
new WPCOM_JSON_API_Update_Post_v1_1_Endpoint( array(
826
	'description' => 'Edit a post.',
827
	'group'       => 'posts',
828
	'stat'        => 'posts:1:POST',
829
	'new_version' => '1.2',
830
	'min_version' => '1.1',
831
	'max_version' => '1.1',
832
	'method'      => 'POST',
833
	'path'        => '/sites/%s/posts/%d',
834
	'path_labels' => array(
835
		'$site'    => '(int|string) Site ID or domain',
836
		'$post_ID' => '(int) The post ID',
837
	),
838
839
	'request_format' => array(
840
		'date'      => "(ISO 8601 datetime) The post's creation time.",
841
		'title'     => '(HTML) The post title.',
842
		'content'   => '(HTML) The post content.',
843
		'excerpt'   => '(HTML) An optional post excerpt.',
844
		'slug'      => '(string) The name (slug) for the post, used in URLs.',
845
		'author'    => '(string) The username or ID for the user to assign the post to.',
846
		'publicize' => '(array|bool) True or false if the post be publicized to external services. An array of services if we only want to publicize to a select few. Defaults to true.',
847
		'publicize_message' => '(string) Custom message to be publicized to external services.',
848
		'status'    => array(
849
			'publish' => 'Publish the post.',
850
			'private' => 'Privately publish the post.',
851
			'draft'   => 'Save the post as a draft.',
852
			'future'  => 'Schedule the post (alias for publish; you must also set a future date).',
853
			'pending' => 'Mark the post as pending editorial approval.',
854
		),
855
		'sticky'    => array(
856
			'false'   => 'Post is not marked as sticky.',
857
			'true'    => 'Stick the post to the front page.',
858
		),
859
		'password'   => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.',
860
		'parent'     => "(int) The post ID of the new post's parent.",
861
		'terms'      => '(object) Mapping of taxonomy to comma-separated list or array of terms (name or id)',
862
		'categories' => "(array|string) Comma-separated list or array of categories (name or id)",
863
		'tags'       => "(array|string) Comma-separated list or array of tags (name or id)",
864
		'format'     => array_merge( array( 'default' => 'Use default post format' ), get_post_format_strings() ),
865
		'discussion' => '(object) A hash containing one or more of the following boolean values, which default to the blog\'s discussion preferences: `comments_open`, `pings_open`',
866
		'likes_enabled' => "(bool) Should the post be open to likes?",
867
		'menu_order'    => "(int) (Pages only) the order pages should appear in. Use 0 to maintain alphabetical order.",
868
		'page_template' => '(string) (Pages Only) The page template this page should use.',
869
		'sharing_enabled' => "(bool) Should sharing buttons show on this post?",
870
		'featured_image' => "(string) The post ID of an existing attachment to set as the featured image. Pass an empty string to delete the existing image.",
871
		'media'      => "(media) An array of files to attach to the post. To upload media, the entire request should be multipart/form-data encoded. Multiple media items will be displayed in a gallery. Accepts  jpg, jpeg, png, gif, pdf, doc, ppt, odt, pptx, docx, pps, ppsx, xls, xlsx, key. Audio and Video may also be available. See <code>allowed_file_types</code> in the options resposne of the site endpoint. <br /><br /><strong>Example</strong>:<br />" .
872
		 				"<code>curl \<br />--form 'title=Image' \<br />--form 'media[]=@/path/to/file.jpg' \<br />-H 'Authorization: BEARER your-token' \<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>",
873
		'media_urls' => "(array) An array of URLs for images to attach to a post. Sideloads the media in for a post.",
874
		'metadata'      => "(array) Array of metadata objects containing the following properties: `key` (metadata key), `id` (meta ID), `previous_value` (if set, the action will only occur for the provided previous value), `value` (the new value to set the meta to), `operation` (the operation to perform: `update` or `add`; defaults to `update`). All unprotected meta keys are available by default for read requests. Both unprotected and protected meta keys are available for authenticated requests with proper capabilities. Protected meta keys can be made available with the <code>rest_api_allowed_public_metadata</code> filter.",
875
	),
876
877
	'example_request'      => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/881',
878
879
	'example_request_data' => array(
880
		'headers' => array(
881
			'authorization' => 'Bearer YOUR_API_TOKEN'
882
		),
883
884
		'body' => array(
885
			'title'      => 'Hello World (Again)',
886
			'content'    => 'Hello. I am an edited post. I was edited by the API',
887
			'tags'       => 'tests',
888
			'categories' => 'API'
889
		)
890
	)
891
) );
892
893
new WPCOM_JSON_API_Update_Post_v1_2_Endpoint( array(
894
	'description' => 'Edit a post.',
895
	'group'       => 'posts',
896
	'stat'        => 'posts:1:POST',
897
	'min_version' => '1.2',
898
	'max_version' => '1.2',
899
	'method'      => 'POST',
900
	'path'        => '/sites/%s/posts/%d',
901
	'path_labels' => array(
902
		'$site'    => '(int|string) Site ID or domain',
903
		'$post_ID' => '(int) The post ID',
904
	),
905
906
	'request_format' => array(
907
		'date'      => "(ISO 8601 datetime) The post's creation time.",
908
		'title'     => '(HTML) The post title.',
909
		'content'   => '(HTML) The post content.',
910
		'excerpt'   => '(HTML) An optional post excerpt.',
911
		'slug'      => '(string) The name (slug) for the post, used in URLs.',
912
		'author'    => '(string) The username or ID for the user to assign the post to.',
913
		'publicize' => '(array|bool) True or false if the post be publicized to external services. An array of services if we only want to publicize to a select few. Defaults to true.',
914
		'publicize_message' => '(string) Custom message to be publicized to external services.',
915
		'status'    => array(
916
			'publish' => 'Publish the post.',
917
			'private' => 'Privately publish the post.',
918
			'draft'   => 'Save the post as a draft.',
919
			'future'  => 'Schedule the post (alias for publish; you must also set a future date).',
920
			'pending' => 'Mark the post as pending editorial approval.',
921
		),
922
		'sticky'    => array(
923
			'false'   => 'Post is not marked as sticky.',
924
			'true'    => 'Stick the post to the front page.',
925
		),
926
		'password'   => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.',
927
		'parent'     => "(int) The post ID of the new post's parent.",
928
		'terms'      => '(object) Mapping of taxonomy to comma-separated list or array of term names',
929
		'terms_by_id' => '(object) Mapping of taxonomy to comma-separated list or array of term IDs',
930
		'categories' => "(array|string) Comma-separated list or array of category names",
931
		'categories_by_id' => "(array|string) Comma-separated list or array of category IDs",
932
		'tags'       => "(array|string) Comma-separated list or array of tag names",
933
		'tags_by_id'       => "(array|string) Comma-separated list or array of tag IDs",
934
		'format'     => array_merge( array( 'default' => 'Use default post format' ), get_post_format_strings() ),
935
		'discussion' => '(object) A hash containing one or more of the following boolean values, which default to the blog\'s discussion preferences: `comments_open`, `pings_open`',
936
		'likes_enabled' => "(bool) Should the post be open to likes?",
937
		'menu_order'    => "(int) (Pages only) the order pages should appear in. Use 0 to maintain alphabetical order.",
938
		'page_template' => '(string) (Pages Only) The page template this page should use.',
939
		'sharing_enabled' => "(bool) Should sharing buttons show on this post?",
940
		'featured_image' => "(string) The post ID of an existing attachment to set as the featured image. Pass an empty string to delete the existing image.",
941
		'media'      => "(media) An array of files to attach to the post. To upload media, the entire request should be multipart/form-data encoded. Multiple media items will be displayed in a gallery. Accepts  jpg, jpeg, png, gif, pdf, doc, ppt, odt, pptx, docx, pps, ppsx, xls, xlsx, key. Audio and Video may also be available. See <code>allowed_file_types</code> in the options resposne of the site endpoint. <br /><br /><strong>Example</strong>:<br />" .
942
		 				"<code>curl \<br />--form 'title=Image' \<br />--form 'media[]=@/path/to/file.jpg' \<br />-H 'Authorization: BEARER your-token' \<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>",
943
		'media_urls' => "(array) An array of URLs for images to attach to a post. Sideloads the media in for a post.",
944
		'metadata'      => "(array) Array of metadata objects containing the following properties: `key` (metadata key), `id` (meta ID), `previous_value` (if set, the action will only occur for the provided previous value), `value` (the new value to set the meta to), `operation` (the operation to perform: `update` or `add`; defaults to `update`). All unprotected meta keys are available by default for read requests. Both unprotected and protected meta keys are available for authenticated requests with proper capabilities. Protected meta keys can be made available with the <code>rest_api_allowed_public_metadata</code> filter.",
945
	),
946
947
	'example_request'      => 'https://public-api.wordpress.com/rest/v1.2/sites/82974409/posts/881',
948
949
	'example_request_data' => array(
950
		'headers' => array(
951
			'authorization' => 'Bearer YOUR_API_TOKEN'
952
		),
953
954
		'body' => array(
955
			'title'      => 'Hello World (Again)',
956
			'content'    => 'Hello. I am an edited post. I was edited by the API',
957
			'tags'       => 'tests',
958
			'categories' => 'API'
959
		)
960
	)
961
) );
962
963
new WPCOM_JSON_API_Update_Post_Endpoint( array(
964
	'description' => 'Delete a post. Note: If the post object is of type post or page and the trash is enabled, this request will send the post to the trash. A second request will permanently delete the post.',
965
	'group'       => 'posts',
966
	'stat'        => 'posts:1:delete',
967
	'new_version' => '1.1',
968
	'max_version' => '1',
969
	'method'      => 'POST',
970
	'path'        => '/sites/%s/posts/%d/delete',
971
	'path_labels' => array(
972
		'$site'    => '(int|string) Site ID or domain',
973
		'$post_ID' => '(int) The post ID',
974
	),
975
976
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/posts/$post_ID/delete/',
977
978
	'example_request_data' => array(
979
		'headers' => array(
980
			'authorization' => 'Bearer YOUR_API_TOKEN'
981
		)
982
	)
983
) );
984
985
new WPCOM_JSON_API_Update_Post_v1_1_Endpoint( array(
986
	'description' => 'Delete a post. Note: If the post object is of type post or page and the trash is enabled, this request will send the post to the trash. A second request will permanently delete the post.',
987
	'group'       => 'posts',
988
	'stat'        => 'posts:1:delete',
989
	'min_version' => '1.1',
990
	'max_version' => '1.1',
991
	'method'      => 'POST',
992
	'path'        => '/sites/%s/posts/%d/delete',
993
	'path_labels' => array(
994
		'$site'    => '(int|string) Site ID or domain',
995
		'$post_ID' => '(int) The post ID',
996
	),
997
998
	'example_request'      => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/$post_ID/delete/',
999
1000
	'example_request_data' => array(
1001
		'headers' => array(
1002
			'authorization' => 'Bearer YOUR_API_TOKEN'
1003
		)
1004
	)
1005
) );
1006
1007
new WPCOM_JSON_API_Update_Post_Endpoint( array(
1008
	'description' => 'Restore a post or page from the trash to its previous status.',
1009
	'group'       => 'posts',
1010
	'stat'        => 'posts:1:restore',
1011
1012
	'method'      => 'POST',
1013
	'new_version' => '1.1',
1014
	'max_version' => '1',
1015
	'path'        => '/sites/%s/posts/%d/restore',
1016
	'path_labels' => array(
1017
		'$site'    => '(int|string) Site ID or domain',
1018
		'$post_ID' => '(int) The post ID',
1019
	),
1020
1021
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/posts/$post_ID/restore/',
1022
1023
	'example_request_data' => array(
1024
		'headers' => array(
1025
			'authorization' => 'Bearer YOUR_API_TOKEN'
1026
		)
1027
	)
1028
) );
1029
1030
new WPCOM_JSON_API_Update_Post_v1_1_Endpoint( array(
1031
	'description' => 'Restore a post or page from the trash to its previous status.',
1032
	'group'       => 'posts',
1033
	'stat'        => 'posts:1:restore',
1034
	'min_version' => '1.1',
1035
	'max_version' => '1.1',
1036
	'method'      => 'POST',
1037
	'path'        => '/sites/%s/posts/%d/restore',
1038
	'path_labels' => array(
1039
		'$site'    => '(int|string) Site ID or domain',
1040
		'$post_ID' => '(int) The post ID',
1041
	),
1042
1043
	'example_request'      => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/$post_ID/restore/',
1044
1045
	'example_request_data' => array(
1046
		'headers' => array(
1047
			'authorization' => 'Bearer YOUR_API_TOKEN'
1048
		)
1049
	)
1050
) );
1051
1052
new WPCOM_JSON_API_Get_Autosave_v1_1_Endpoint( array(
1053
	'description' => 'Get the most recent autosave for a post.',
1054
	'group'       => '__do_not_document',
1055
	'stat'        => 'posts:autosave',
1056
	'min_version' => '1.1',
1057
	'method'      => 'GET',
1058
	'path'        => '/sites/%s/posts/%d/autosave',
1059
	'path_labels' => array(
1060
		'$site'    => '(int|string) Site ID or domain',
1061
		'$post_ID' => '(int) The post ID',
1062
	),
1063
	'response_format' => array(
1064
		'ID'          => '(int) autodraft post ID',
1065
		'post_ID'     => '(int) post ID',
1066
		'author_ID'   => '(int) author ID',
1067
		'title'       => '(HTML) The post title.',
1068
		'content'     => '(HTML) The post content.',
1069
		'excerpt'     => '(HTML) The post excerpt.',
1070
		'preview_URL' => '(string) preview URL for the post',
1071
		'modified'    => '(ISO 8601 datetime) modified time',
1072
	),
1073
1074
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/1/autosave',
1075
) );
1076
1077
new WPCOM_JSON_API_Autosave_Post_v1_1_Endpoint( array(
1078
	'description' => 'Create a post autosave.',
1079
	'group'       => '__do_not_document',
1080
	'stat'        => 'posts:autosave',
1081
	'min_version' => '1.1',
1082
	'method'      => 'POST',
1083
	'path'        => '/sites/%s/posts/%d/autosave',
1084
	'path_labels' => array(
1085
		'$site'    => '(int|string) Site ID or domain',
1086
		'$post_ID' => '(int) The post ID',
1087
	),
1088
	'request_format' => array(
1089
		'content' => '(HTML) The post content.',
1090
		'title'   => '(HTML) The post title.',
1091
		'excerpt' => '(HTML) The post excerpt.',
1092
	),
1093
	'response_format' => array(
1094
		'ID'          => '(int) autodraft post ID',
1095
		'post_ID'     => '(int) post ID',
1096
		'preview_URL' => '(string) preview URL for the post',
1097
		'modified'    => '(ISO 8601 datetime) modified time',
1098
	),
1099
1100
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/1/autosave',
1101
1102
	'example_request_data' => array(
1103
		'headers' => array(
1104
			'authorization' => 'Bearer YOUR_API_TOKEN'
1105
		),
1106
1107
		'body' => array(
1108
			'title'    => 'Howdy',
1109
			'content'    => 'Hello. I am a test post. I was created by the API',
1110
		)
1111
	)
1112
) );
1113
1114
/*
1115
 * Media Endpoints
1116
 */
1117
new WPCOM_JSON_API_List_Media_Endpoint( array(
1118
	'description' => 'Get a list of items in the media library.',
1119
	'group'       => 'media',
1120
	'stat'        => 'media',
1121
1122
	'method'      => 'GET',
1123
	'path'        => '/sites/%s/media/',
1124
	'deprecated'  => true,
1125
	'new_version' => '1.1',
1126
	'max_version' => '1',
1127
	'path_labels' => array(
1128
		'$site' => '(int|string) Site ID or domain',
1129
	),
1130
1131
	'query_parameters' => array(
1132
		'number'    => '(int=20) The number of media items to return. Limit: 100.',
1133
		'offset'    => '(int=0) 0-indexed offset.',
1134
		'parent_id' => '(int) Default is showing all items. The post where the media item is attached. 0 shows unattached media items.',
1135
		'mime_type' => "(string) Default is empty. Filter by mime type (e.g., 'image/jpeg', 'application/pdf'). Partial searches also work (e.g. passing 'image' will search for all image files).",
1136
	),
1137
1138
	'response_format' => array(
1139
		'media' => '(array) Array of media',
1140
		'found' => '(int) The number of total results found'
1141
	),
1142
1143
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/media/?number=2',
1144
	'example_request_data' =>  array(
1145
		'headers' => array(
1146
			'authorization' => 'Bearer YOUR_API_TOKEN'
1147
		)
1148
	)
1149
) );
1150
1151
new WPCOM_JSON_API_List_Media_v1_1_Endpoint( array(
1152
	'description' => 'Get a list of items in the media library.',
1153
	'group'       => 'media',
1154
	'stat'        => 'media',
1155
	'min_version' => '1.1',
1156
	'max_version' => '1.1',
1157
	'method'      => 'GET',
1158
	'path'        => '/sites/%s/media/',
1159
	'path_labels' => array(
1160
		'$site' => '(int|string) Site ID or domain',
1161
	),
1162
1163
	'query_parameters' => array(
1164
		'number'    => '(int=20) The number of media items to return. Limit: 100.',
1165
		'offset'    => '(int=0) 0-indexed offset.',
1166
		'page'     => '(int) Return the Nth 1-indexed page of posts. Takes precedence over the <code>offset</code> parameter.',
1167
		'page_handle' => '(string) A page handle, returned from a previous API call as a <code>meta.next_page</code> property. This is the most efficient way to fetch the next page of results.',
1168
		'order'    => array(
1169
			'DESC' => 'Return files in descending order. For dates, that means newest to oldest.',
1170
			'ASC'  => 'Return files in ascending order. For dates, that means oldest to newest.',
1171
		),
1172
		'order_by' => array(
1173
			'date'          => 'Order by the uploaded time of each file.',
1174
			'title'         => "Order lexicographically by file titles.",
1175
			'ID'            => 'Order by media ID.',
1176
		),
1177
		'search'    => '(string) Search query.',
1178
		'post_ID'   => '(int) Default is showing all items. The post where the media item is attached. 0 shows unattached media items.',
1179
		'mime_type' => "(string) Default is empty. Filter by mime type (e.g., 'image/jpeg', 'application/pdf'). Partial searches also work (e.g. passing 'image' will search for all image files).",
1180
		'after'     => '(ISO 8601 datetime) Return media items uploaded after the specified datetime.',
1181
		'before'    => '(ISO 8601 datetime) Return media items uploaded before the specified datetime.',
1182
	),
1183
1184
	'response_format' => array(
1185
		'media' => '(array) Array of media objects',
1186
		'found' => '(int) The number of total results found'
1187
	),
1188
1189
	'example_request'      => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/media',
1190
	'example_request_data' =>  array(
1191
		'headers' => array(
1192
			'authorization' => 'Bearer YOUR_API_TOKEN'
1193
		)
1194
	)
1195
) );
1196
1197
new WPCOM_JSON_API_Get_Media_Endpoint( array(
1198
	'description' => 'Get a single media item (by ID).',
1199
	'group'       => 'media',
1200
	'stat'        => 'media:1',
1201
	'method'      => 'GET',
1202
	'path'        => '/sites/%s/media/%d',
1203
	'deprecated'  => true,
1204
	'new_version' => '1.1',
1205
	'max_version' => '1',
1206
	'path_labels' => array(
1207
		'$site'    => '(int|string) Site ID or domain',
1208
		'$media_ID' => '(int) The ID of the media item',
1209
	),
1210
	'response_format' => array(
1211
		'id'    => '(int) The ID of the media item',
1212
		'date' =>  '(ISO 8601 datetime) The date the media was uploaded',
1213
		'parent'           => '(int) ID of the post this media is attached to',
1214
		'link'             => '(string) URL to the file',
1215
		'title'            => '(string) Filename',
1216
		'caption'          => '(string) User-provided caption of the file',
1217
		'description'      => '(string) Description of the file',
1218
		'metadata'         => '(array) Array of metadata about the file, such as Exif data or sizes',
1219
	),
1220
1221
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/media/934',
1222
	'example_request_data' =>  array(
1223
		'headers' => array(
1224
			'authorization' => 'Bearer YOUR_API_TOKEN'
1225
		)
1226
	)
1227
) );
1228
1229
new WPCOM_JSON_API_Get_Media_v1_1_Endpoint( array(
1230
	'description' => 'Get a single media item (by ID).',
1231
	'group'       => 'media',
1232
	'stat'        => 'media:1',
1233
	'min_version' => '1.1',
1234
	'max_version' => '1.1',
1235
	'method'      => 'GET',
1236
	'path'        => '/sites/%s/media/%d',
1237
	'path_labels' => array(
1238
		'$site'    => '(int|string) Site ID or domain',
1239
		'$media_ID' => '(int) The ID of the media item',
1240
	),
1241
	'response_format' => array(
1242
		'ID'               => '(int) The ID of the media item',
1243
		'date'             => '(ISO 8601 datetime) The date the media was uploaded',
1244
		'post_ID'          => '(int) ID of the post this media is attached to',
1245
		'author_ID'        => '(int) ID of the user who uploaded the media',
1246
		'URL'              => '(string) URL to the file',
1247
		'guid'             => '(string) Unique identifier',
1248
		'file'			   => '(string) Filename',
1249
		'extension'        => '(string) File extension',
1250
		'mime_type'        => '(string) File MIME type',
1251
		'title'            => '(string) Filename',
1252
		'caption'          => '(string) User-provided caption of the file',
1253
		'description'      => '(string) Description of the file',
1254
		'alt'              => '(string)  Alternative text for image files.',
1255
		'thumbnails'       => '(object) Media item thumbnail URL options',
1256
		'height'           => '(int) (Image & video only) Height of the media item',
1257
		'width'            => '(int) (Image & video only) Width of the media item',
1258
		'length'           => '(int) (Video & audio only) Duration of the media item, in seconds',
1259
		'exif'             => '(array) (Image & audio only) Exif (meta) information about the media item',
1260
		'videopress_guid'  => '(string) (Video only) VideoPress GUID of the video when uploaded on a blog with VideoPress',
1261
		'videopress_processing_done'  => '(bool) (Video only) If the video is uploaded on a blog with VideoPress, this will return the status of processing on the video.'
1262
	),
1263
1264
	'example_request'      => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/media/934',
1265
	'example_request_data' =>  array(
1266
		'headers' => array(
1267
			'authorization' => 'Bearer YOUR_API_TOKEN'
1268
		)
1269
	)
1270
) );
1271
1272
new WPCOM_JSON_API_Upload_Media_Endpoint( array(
1273
	'description' => 'Upload a new media item.',
1274
	'group'       => 'media',
1275
	'stat'        => 'media:new',
1276
	'method'      => 'POST',
1277
	'path'        => '/sites/%s/media/new',
1278
	'deprecated'  => true,
1279
	'new_version' => '1.1',
1280
	'max_version' => '1',
1281
	'path_labels' => array(
1282
		'$site' => '(int|string) Site ID or domain',
1283
	),
1284
1285
	'request_format' => array(
1286
		'media'      => "(media) An array of media to attach to the post. To upload media, the entire request should be multipart/form-data encoded. Accepts images (image/gif, image/jpeg, image/png) only at this time.<br /><br /><strong>Example</strong>:<br />" .
1287
		                "<code>curl \<br />--form 'media[]=@/path/to/file.jpg' \<br />-H 'Authorization: BEARER your-token' \<br />'https://public-api.wordpress.com/rest/v1/sites/123/media/new'</code>",
1288
		'media_urls' => "(array) An array of URLs to upload to the post."
1289
	),
1290
1291
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/media/new/',
1292
1293
	'response_format' => array(
1294
		'media' => '(array) Array of uploaded media',
1295
		'errors' => '(array) Array of error messages of uploading media failures'
1296
	),
1297
	'example_request_data' =>  array(
1298
		'headers' => array(
1299
			'authorization' => 'Bearer YOUR_API_TOKEN'
1300
		),
1301
		'body' => array(
1302
			'media_urls' => "https://s.w.org/about/images/logos/codeispoetry-rgb.png"
1303
		)
1304
	)
1305
) );
1306
1307
new WPCOM_JSON_API_Upload_Media_v1_1_Endpoint( array(
1308
	'description' => 'Upload a new piece of media.',
1309
	'group'       => 'media',
1310
	'stat'        => 'media:new',
1311
	'min_version' => '1.1',
1312
	'max_version' => '1.1',
1313
	'method'      => 'POST',
1314
	'path'        => '/sites/%s/media/new',
1315
	'path_labels' => array(
1316
		'$site' => '(int|string) Site ID or domain',
1317
	),
1318
1319
	'request_format' => array(
1320
		'media'      => "(media) An array of media to attach to the post. To upload media, the entire request should be multipart/form-data encoded. Accepts  jpg, jpeg, png, gif, pdf, doc, ppt, odt, pptx, docx, pps, ppsx, xls, xlsx, key. Audio and Video may also be available. See <code>allowed_file_types</code> in the options response of the site endpoint.<br /><br /><strong>Example</strong>:<br />" .
1321
		                "<code>curl \<br />--form 'media[]=@/path/to/file.jpg' \<br />-H 'Authorization: BEARER your-token' \<br />'https://public-api.wordpress.com/rest/v1/sites/123/media/new'</code>",
1322
		'media_urls' => "(array) An array of URLs to upload to the post. Errors produced by media uploads, if any, will be in `media_errors` in the response.",
1323
		'attrs' => "(array) An array of attributes (`title`, `description`, `caption` `alt` for images, `artist` for audio, `album` for audio, and `parent_id`) are supported to assign to the media uploaded via the `media` or `media_urls` properties. You must use a numeric index for the keys of `attrs` which follows the same sequence as `media` and `media_urls`. <br /><br /><strong>Example</strong>:<br />" .
1324
		                 "<code>curl \<br />--form 'media[]=@/path/to/file1.jpg' \<br />--form 'media_urls[]=http://example.com/file2.jpg' \<br /> \<br />--form 'attrs[0][caption]=This will be the caption for file1.jpg' \<br />--form 'attrs[1][title]=This will be the title for file2.jpg' \<br />-H 'Authorization: BEARER your-token' \<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>",
1325
	),
1326
1327
	'response_format' => array(
1328
		'media' => '(array) Array of uploaded media objects',
1329
		'errors' => '(array) Array of error messages of uploading media failures'
1330
	),
1331
1332
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/media/new',
1333
	'example_request_data' =>  array(
1334
		'headers' => array(
1335
			'authorization' => 'Bearer YOUR_API_TOKEN'
1336
		),
1337
		'body' => array(
1338
			'media_urls' => "https://s.w.org/about/images/logos/codeispoetry-rgb.png"
1339
		)
1340
	)
1341
) );
1342
1343
new WPCOM_JSON_API_Update_Media_Endpoint( array(
1344
	'description' => 'Edit basic information about a media item.',
1345
	'group'       => 'media',
1346
	'stat'        => 'media:1:POST',
1347
	'method'      => 'POST',
1348
	'path'        => '/sites/%s/media/%d',
1349
	'deprecated'  => true,
1350
	'new_version' => '1.1',
1351
	'path_labels' => array(
1352
		'$site'    => '(int|string) Site ID or domain',
1353
		'$media_ID' => '(int) The ID of the media item',
1354
	),
1355
1356
	'request_format' => array(
1357
		'title'       => '(string) The file name.',
1358
		'caption'     => '(string) File caption.',
1359
		'description' => '(HTML) Description of the file.',
1360
	),
1361
1362
	'response_format' => array(
1363
		'id'          => '(int) The ID of the media item',
1364
		'date'        =>  '(ISO 8601 datetime) The date the media was uploaded',
1365
		'parent'      => '(int) ID of the post this media is attached to',
1366
		'link'        => '(string) URL to the file',
1367
		'title'       => '(string) File name',
1368
		'caption'     => '(string) User provided caption of the file',
1369
		'description' => '(string) Description of the file',
1370
		'metadata'    => '(array) Array of metadata about the file, such as Exif data or sizes',
1371
	),
1372
	'example_request'      => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/media/446',
1373
	'example_request_data' =>  array(
1374
		'headers' => array(
1375
			'authorization' => 'Bearer YOUR_API_TOKEN'
1376
		),
1377
		'body' => array(
1378
			'title' => 'Updated Title'
1379
		)
1380
	)
1381
) );
1382
1383
new WPCOM_JSON_API_Update_Media_v1_1_Endpoint( array(
1384
	'description' => 'Edit basic information about a media item.',
1385
	'group'       => 'media',
1386
	'stat'        => 'media:1:POST',
1387
	'min_version' => '1.1',
1388
	'max_version' => '1.1',
1389
	'method'      => 'POST',
1390
	'path'        => '/sites/%s/media/%d',
1391
	'path_labels' => array(
1392
		'$site'    => '(int|string) Site ID or domain',
1393
		'$media_ID' => '(int) The ID of the media item',
1394
	),
1395
1396
	'request_format' => array(
1397
		'parent_id'   => '(int) ID of the post this media is attached to',
1398
		'title'       => '(string) The file name.',
1399
		'caption'     => '(string) File caption.',
1400
		'description' => '(HTML) Description of the file.',
1401
		'alt'         => "(string) Alternative text for image files.",
1402
		'artist'      => "(string) Audio Only. Artist metadata for the audio track.",
1403
		'album'       => "(string) Audio Only. Album metadata for the audio track.",
1404
	),
1405
1406
	'response_format' => array(
1407
		'ID'               => '(int) The ID of the media item',
1408
		'date'             => '(ISO 8601 datetime) The date the media was uploaded',
1409
		'post_ID'          => '(int) ID of the post this media is attached to',
1410
		'author_ID'        => '(int) ID of the user who uploaded the media',
1411
		'URL'              => '(string) URL to the file',
1412
		'guid'             => '(string) Unique identifier',
1413
		'file'			   => '(string) File name',
1414
		'extension'        => '(string) File extension',
1415
		'mime_type'        => '(string) File mime type',
1416
		'title'            => '(string) File name',
1417
		'caption'          => '(string) User provided caption of the file',
1418
		'description'      => '(string) Description of the file',
1419
		'alt'              => '(string)  Alternative text for image files.',
1420
		'thumbnails'       => '(object) Media item thumbnail URL options',
1421
		'height'           => '(int) (Image & video only) Height of the media item',
1422
		'width'            => '(int) (Image & video only) Width of the media item',
1423
		'length'           => '(int) (Video & audio only) Duration of the media item, in seconds',
1424
		'exif'             => '(array) (Image & audio only) Exif (meta) information about the media item',
1425
		'videopress_guid'  => '(string) (Video only) VideoPress GUID of the video when uploaded on a blog with VideoPress',
1426
		'videopress_processing_done'  => '(bool) (Video only) If the video is uploaded on a blog with VideoPress, this will return the status of processing on the video.'
1427
	),
1428
1429
	'example_request'      => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/media/446',
1430
	'example_request_data' =>  array(
1431
		'headers' => array(
1432
			'authorization' => 'Bearer YOUR_API_TOKEN'
1433
		),
1434
		'body' => array(
1435
			'title' => 'Updated Title'
1436
		)
1437
	)
1438
) );
1439
1440
1441
new WPCOM_JSON_API_Delete_Media_Endpoint( array(
1442
	'description' => 'Delete a piece of media.',
1443
	'group'       => 'media',
1444
	'stat'        => 'media:1:delete',
1445
	'method'      => 'POST',
1446
	'path'        => '/sites/%s/media/%d/delete',
1447
	'deprecated'  => true,
1448
	'new_version' => '1.1',
1449
	'max_version' => '1',
1450
	'path_labels' => array(
1451
		'$site'    => '(int|string) Site ID or domain',
1452
		'$media_ID' => '(int) The media ID',
1453
	),
1454
1455
	'response_format' => array(
1456
		'status' => '(string) Returns deleted if the media was successfully deleted',
1457
		'id'    => '(int) The ID of the media item',
1458
		'date' =>  '(ISO 8601 datetime) The date the media was uploaded',
1459
		'parent'           => '(int) ID of the post this media is attached to',
1460
		'link'             => '(string) URL to the file',
1461
		'title'            => '(string) File name',
1462
		'caption'          => '(string) User provided caption of the file',
1463
		'description'      => '(string) Description of the file',
1464
		'metadata'         => '(array) Misc array of information about the file, such as exif data or sizes',
1465
	),
1466
1467
	'example_request'      => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/media/$media_ID/delete',
1468
	'example_request_data' =>  array(
1469
		'headers' => array(
1470
			'authorization' => 'Bearer YOUR_API_TOKEN'
1471
		)
1472
	)
1473
) );
1474
1475
new WPCOM_JSON_API_Delete_Media_v1_1_Endpoint( array(
1476
	'description' => 'Delete a piece of media. Note: Media is deleted and not trashed.',
1477
	'group'       => 'media',
1478
	'stat'        => 'media:1:delete',
1479
	'min_version' => '1.1',
1480
	'max_version' => '1.1',
1481
	'method'      => 'POST',
1482
	'path'        => '/sites/%s/media/%d/delete',
1483
	'path_labels' => array(
1484
		'$site'    => '(int|string) Site ID or domain',
1485
		'$media_ID' => '(int) The media ID',
1486
	),
1487
1488
	'response_format' => array(
1489
		'status'           => '(string) Returns deleted if the media was successfully deleted',
1490
		'ID'               => '(int) The ID of the media item',
1491
		'date'             => '(ISO 8601 datetime) The date the media was uploaded',
1492
		'post_ID'          => '(int) ID of the post this media is attached to',
1493
		'author_ID'        => '(int) ID of the user who uploaded the media',
1494
		'URL'              => '(string) URL to the file',
1495
		'guid'             => '(string) Unique identifier',
1496
		'file'			   => '(string) File name',
1497
		'extension'        => '(string) File extension',
1498
		'mime_type'        => '(string) File mime type',
1499
		'title'            => '(string) File name',
1500
		'caption'          => '(string) User-provided caption of the file',
1501
		'description'      => '(string) Description of the file',
1502
		'alt'              => '(string)  Alternative text for image files.',
1503
		'thumbnails'       => '(object) Media item thumbnail URL options',
1504
		'height'           => '(int) (Image & video only) Height of the media item',
1505
		'width'            => '(int) (Image & video only) Width of the media item',
1506
		'length'           => '(int) (Video & audio only) Duration of the media item, in seconds',
1507
		'exif'             => '(array) (Image & audio only) Exif (meta) information about the media item',
1508
		'videopress_guid'  => '(string) (Video only) VideoPress GUID of the video when uploaded on a blog with VideoPress',
1509
		'videopress_processing_done'  => '(bool) (Video only) If the video is Uuploaded on a blog with VideoPress, this will return the status of processing on the Video'
1510
	),
1511
1512
	'example_request'      => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/media/$media_ID/delete',
1513
	'example_request_data' =>  array(
1514
		'headers' => array(
1515
			'authorization' => 'Bearer YOUR_API_TOKEN'
1516
		)
1517
	)
1518
) );
1519
1520
/*
1521
 * Comment endpoints
1522
 */
1523
new WPCOM_JSON_API_List_Comments_Endpoint( array(
1524
	'description' => 'Get a list of recent comments.',
1525
	'group'       => 'comments',
1526
	'stat'        => 'comments',
1527
1528
	'method'      => 'GET',
1529
	'path'        => '/sites/%s/comments/',
1530
	'path_labels' => array(
1531
		'$site' => '(int|string) Site ID or domain',
1532
	),
1533
1534
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/comments/?number=2'
1535
) );
1536
1537
new WPCOM_JSON_API_List_Comments_Endpoint( array(
1538
	'description' => 'Get a list of recent comments on a post.',
1539
	'group'       => 'comments',
1540
	'stat'        => 'posts:1:replies',
1541
1542
	'method'      => 'GET',
1543
	'path'        => '/sites/%s/posts/%d/replies/',
1544
	'path_labels' => array(
1545
		'$site'    => '(int|string) Site ID or domain',
1546
		'$post_ID' => '(int) The post ID',
1547
	),
1548
1549
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/posts/7/replies/?number=2'
1550
) );
1551
1552
new WPCOM_JSON_API_Get_Comment_Endpoint( array(
1553
	'description' => 'Get a single comment.',
1554
	'group'       => 'comments',
1555
	'stat'        => 'comments:1',
1556
1557
	'method'      => 'GET',
1558
	'path'        => '/sites/%s/comments/%d',
1559
	'path_labels' => array(
1560
		'$site'       => '(int|string) Site ID or domain',
1561
		'$comment_ID' => '(int) The comment ID'
1562
	),
1563
1564
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/comments/147564'
1565
) );
1566
1567
new WPCOM_JSON_API_Update_Comment_Endpoint( array(
1568
	'description' => 'Create a comment on a post.',
1569
	'group'       => 'comments',
1570
	'stat'        => 'posts:1:replies:new',
1571
1572
	'method'      => 'POST',
1573
	'path'        => '/sites/%s/posts/%d/replies/new',
1574
	'path_labels' => array(
1575
		'$site'    => '(int|string) Site ID or domain',
1576
		'$post_ID' => '(int) The post ID'
1577
	),
1578
1579
	'request_format' => array(
1580
		// explicitly document all input
1581
		'content'   => '(HTML) The comment text.',
1582
//		@todo Should we open this up to unauthenticated requests too?
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
1583
//		'author'    => '(author object) The author of the comment.',
1584
	),
1585
1586
	'pass_wpcom_user_details' => true,
1587
1588
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/posts/843/replies/new/',
1589
	'example_request_data' =>  array(
1590
		'headers' => array(
1591
			'authorization' => 'Bearer YOUR_API_TOKEN'
1592
		),
1593
		'body' => array(
1594
			'content' => 'Your reply is very interesting. This is a reply.'
1595
		)
1596
	)
1597
) );
1598
1599
new WPCOM_JSON_API_Update_Comment_Endpoint( array(
1600
	'description' => 'Create a comment as a reply to another comment.',
1601
	'group'       => 'comments',
1602
	'stat'        => 'comments:1:replies:new',
1603
1604
	'method'      => 'POST',
1605
	'path'        => '/sites/%s/comments/%d/replies/new',
1606
	'path_labels' => array(
1607
		'$site'       => '(int|string) Site ID or domain',
1608
		'$comment_ID' => '(int) The comment ID'
1609
	),
1610
1611
	'request_format' => array(
1612
		'content'   => '(HTML) The comment text.',
1613
//		@todo Should we open this up to unauthenticated requests too?
1614
//		'author'    => '(author object) The author of the comment.',
1615
	),
1616
1617
	'pass_wpcom_user_details' => true,
1618
1619
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/comments/29/replies/new',
1620
	'example_request_data' => array(
1621
		'headers' => array(
1622
			'authorization' => 'Bearer YOUR_API_TOKEN'
1623
		),
1624
		'body' => array(
1625
			'content' => 'This reply is very interesting. This is editing a comment reply via the API.',
1626
		)
1627
	)
1628
) );
1629
1630
new WPCOM_JSON_API_Update_Comment_Endpoint( array(
1631
	'description' => 'Edit a comment.',
1632
	'group'       => 'comments',
1633
	'stat'        => 'comments:1:POST',
1634
1635
	'method'      => 'POST',
1636
	'path'        => '/sites/%s/comments/%d',
1637
	'path_labels' => array(
1638
		'$site'       => '(int|string) Site ID or domain',
1639
		'$comment_ID' => '(int) The comment ID'
1640
	),
1641
1642
	'request_format' => array(
1643
		'date'    => "(ISO 8601 datetime) The comment's creation time.",
1644
		'content' => '(HTML) The comment text.',
1645
		'status'  => array(
1646
			'approved'   => 'Approve the comment.',
1647
			'unapproved' => 'Remove the comment from public view and send it to the moderation queue.',
1648
			'spam'       => 'Mark the comment as spam.',
1649
			'unspam'     => 'Unmark the comment as spam. Will attempt to set it to the previous status.',
1650
			'trash'      => 'Send a comment to the trash if trashing is enabled (see constant: EMPTY_TRASH_DAYS).',
1651
			'untrash'    => 'Untrash a comment. Only works when the comment is in the trash.',
1652
		),
1653
	),
1654
1655
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/comments/29',
1656
	'example_request_data' => array(
1657
		'headers' => array(
1658
			'authorization' => 'Bearer YOUR_API_TOKEN'
1659
		),
1660
		'body' => array(
1661
			'content' => 'This reply is now edited via the API.',
1662
			'status'  => 'approved',
1663
		)
1664
	)
1665
) );
1666
1667
new WPCOM_JSON_API_Update_Comment_Endpoint( array(
1668
	'description' => 'Delete a comment.',
1669
	'group'       => 'comments',
1670
	'stat'        => 'comments:1:delete',
1671
1672
	'method'      => 'POST',
1673
	'path'        => '/sites/%s/comments/%d/delete',
1674
	'path_labels' => array(
1675
		'$site'       => '(int|string) Site ID or domain',
1676
		'$comment_ID' => '(int) The comment ID'
1677
	),
1678
1679
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/comments/$comment_ID/delete',
1680
	'example_request_data' => array(
1681
		'headers' => array(
1682
			'authorization' => 'Bearer YOUR_API_TOKEN'
1683
		)
1684
	)
1685
) );
1686
1687
/**
1688
 * Taxonomy Management Endpoints
1689
 */
1690
new WPCOM_JSON_API_Get_Taxonomy_Endpoint( array(
1691
	'description' => 'Get information about a single category.',
1692
	'group'       => 'taxonomy',
1693
	'stat'        => 'categories:1',
1694
1695
	'method'      => 'GET',
1696
	'path'        => '/sites/%s/categories/slug:%s',
1697
	'path_labels' => array(
1698
		'$site'     => '(int|string) Site ID or domain',
1699
		'$category' => '(string) The category slug'
1700
	),
1701
1702
	'example_request'  => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/categories/slug:community'
1703
) );
1704
1705
new WPCOM_JSON_API_Get_Taxonomies_Endpoint( array(
1706
	'description' => "Get a list of a site's categories.",
1707
	'group'       => 'taxonomy',
1708
	'stat'        => 'categories',
1709
	'method'      => 'GET',
1710
	'path'        => '/sites/%s/categories',
1711
	'path_labels' => array(
1712
		'$site'     => '(int|string) Site ID or domain'
1713
	),
1714
	'query_parameters' => array(
1715
		'number'   => '(int=100) The number of categories to return. Limit: 1000.',
1716
		'offset'   => '(int=0) 0-indexed offset.',
1717
		'page'     => '(int) Return the Nth 1-indexed page of categories. Takes precedence over the <code>offset</code> parameter.',
1718
		'search'   => '(string) Limit response to include only categories whose names or slugs match the provided search query.',
1719
		'order'    => array(
1720
			'ASC'  => 'Return categories in ascending order.',
1721
			'DESC' => 'Return categories in descending order.',
1722
		),
1723
		'order_by' => array(
1724
			'name'  => 'Order by the name of each category.',
1725
			'count' => 'Order by the number of posts in each category.',
1726
		),
1727
	),
1728
	'response_format' => array(
1729
		'found'      => '(int) The number of categories returned.',
1730
		'categories' => '(array) Array of category objects.',
1731
	),
1732
	'example_request'  => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/categories/?number=5'
1733
) );
1734
1735
new WPCOM_JSON_API_Get_Taxonomies_Endpoint( array(
1736
	'description' => "Get a list of a site's tags.",
1737
	'group'       => 'taxonomy',
1738
	'stat'        => 'tags',
1739
	'method'      => 'GET',
1740
	'path'        => '/sites/%s/tags',
1741
	'path_labels' => array(
1742
		'$site'     => '(int|string) Site ID or domain'
1743
	),
1744
	'query_parameters' => array(
1745
		'number'   => '(int=100) The number of tags to return. Limit: 1000.',
1746
		'offset'   => '(int=0) 0-indexed offset.',
1747
		'page'     => '(int) Return the Nth 1-indexed page of tags. Takes precedence over the <code>offset</code> parameter.',
1748
		'search'   => '(string) Limit response to include only tags whose names or slugs match the provided search query.',
1749
		'order'    => array(
1750
			'ASC'  => 'Return tags in ascending order.',
1751
			'DESC' => 'Return tags in descending order.',
1752
		),
1753
		'order_by' => array(
1754
			'name'  => 'Order by the name of each tag.',
1755
			'count' => 'Order by the number of posts in each tag.',
1756
		),
1757
	),
1758
	'response_format' => array(
1759
		'found'    => '(int) The number of tags returned.',
1760
		'tags'     => '(array) Array of tag objects.',
1761
	),
1762
	'example_request'  => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/tags/?number=5'
1763
) );
1764
1765
new WPCOM_JSON_API_Get_Taxonomy_Endpoint( array(
1766
	'description' => 'Get information about a single tag.',
1767
	'group'       => 'taxonomy',
1768
	'stat'        => 'tags:1',
1769
1770
	'method'      => 'GET',
1771
	'path'        => '/sites/%s/tags/slug:%s',
1772
	'path_labels' => array(
1773
		'$site' => '(int|string) Site ID or domain',
1774
		'$tag'  => '(string) The tag slug'
1775
	),
1776
1777
	'example_request'  => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/tags/slug:wordpresscom'
1778
) );
1779
1780
new WPCOM_JSON_API_Update_Taxonomy_Endpoint( array(
1781
	'description' => 'Create a new category.',
1782
	'group'       => 'taxonomy',
1783
	'stat'        => 'categories:new',
1784
1785
	'method'      => 'POST',
1786
	'path'        => '/sites/%s/categories/new',
1787
	'path_labels' => array(
1788
		'$site' => '(int|string) Site ID or domain',
1789
	),
1790
1791
	'request_format' => array(
1792
		'name'        => '(string) Name of the category',
1793
		'description' => '(string) A description of the category',
1794
		'parent'      => '(int) ID of the parent category',
1795
	),
1796
1797
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/categories/new/',
1798
	'example_request_data' => array(
1799
		'headers' => array(
1800
			'authorization' => 'Bearer YOUR_API_TOKEN'
1801
		),
1802
		'body' => array(
1803
			'name' => 'Puppies',
1804
		)
1805
	)
1806
) );
1807
1808
new WPCOM_JSON_API_Update_Taxonomy_Endpoint( array(
1809
	'description' => 'Create a new tag.',
1810
	'group'       => 'taxonomy',
1811
	'stat'        => 'tags:new',
1812
1813
	'method'      => 'POST',
1814
	'path'        => '/sites/%s/tags/new',
1815
	'path_labels' => array(
1816
		'$site' => '(int|string) Site ID or domain',
1817
	),
1818
1819
	'request_format' => array(
1820
		'name'        => '(string) Name of the tag',
1821
		'description' => '(string) A description of the tag',
1822
	),
1823
1824
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/tags/new/',
1825
	'example_request_data' => array(
1826
		'headers' => array(
1827
			'authorization' => 'Bearer YOUR_API_TOKEN'
1828
		),
1829
		'body' => array(
1830
			'name' => 'Kitties'
1831
		)
1832
	)
1833
) );
1834
1835
new WPCOM_JSON_API_Update_Taxonomy_Endpoint( array(
1836
	'description' => 'Edit a tag.',
1837
	'group'       => 'taxonomy',
1838
	'stat'        => 'tags:1:POST',
1839
1840
	'method'      => 'POST',
1841
	'path'        => '/sites/%s/tags/slug:%s',
1842
	'path_labels' => array(
1843
		'$site' => '(int|string) Site ID or domain',
1844
		'$tag'  => '(string) The tag slug',
1845
	),
1846
1847
	'request_format' => array(
1848
		'name'        => '(string) Name of the tag',
1849
		'description' => '(string) A description of the tag',
1850
	),
1851
1852
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/tags/slug:testing-tag',
1853
	'example_request_data' => array(
1854
		'headers' => array(
1855
			'authorization' => 'Bearer YOUR_API_TOKEN'
1856
		),
1857
		'body' => array(
1858
			'description' => 'Kitties are awesome!'
1859
		)
1860
	)
1861
) );
1862
1863
new WPCOM_JSON_API_Update_Taxonomy_Endpoint( array(
1864
	'description' => 'Edit a category.',
1865
	'group'       => 'taxonomy',
1866
	'stat'        => 'categories:1:POST',
1867
1868
	'method'      => 'POST',
1869
	'path'        => '/sites/%s/categories/slug:%s',
1870
	'path_labels' => array(
1871
		'$site'     => '(int|string) Site ID or domain',
1872
		'$category' => '(string) The category slug',
1873
	),
1874
1875
	'request_format' => array(
1876
		'name'        => '(string) Name of the category',
1877
		'description' => '(string) A description of the category',
1878
		'parent'      => '(int) ID of the parent category',
1879
	),
1880
1881
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/categories/slug:testing-category',
1882
	'example_request_data' => array(
1883
		'headers' => array(
1884
			'authorization' => 'Bearer YOUR_API_TOKEN'
1885
		),
1886
		'body' => array(
1887
			'description' => 'Puppies are great!'
1888
		)
1889
	)
1890
) );
1891
1892
new WPCOM_JSON_API_Update_Taxonomy_Endpoint( array(
1893
	'description' => 'Delete a category.',
1894
	'group'       => 'taxonomy',
1895
	'stat'        => 'categories:1:delete',
1896
1897
	'method'      => 'POST',
1898
	'path'        => '/sites/%s/categories/slug:%s/delete',
1899
	'path_labels' => array(
1900
		'$site'     => '(int|string) Site ID or domain',
1901
		'$category' => '(string) The category slug',
1902
	),
1903
	'response_format' => array(
1904
		'slug'    => '(string) The slug of the deleted category',
1905
		'success' => '(bool) Was the operation successful?',
1906
	),
1907
1908
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/categories/slug:$category/delete',
1909
	'example_request_data' => array(
1910
		'headers' => array(
1911
			'authorization' => 'Bearer YOUR_API_TOKEN'
1912
		),
1913
	)
1914
) );
1915
1916
new WPCOM_JSON_API_Update_Taxonomy_Endpoint( array(
1917
	'description' => 'Delete a tag.',
1918
	'group'       => 'taxonomy',
1919
	'stat'        => 'tags:1:delete',
1920
1921
	'method'      => 'POST',
1922
	'path'        => '/sites/%s/tags/slug:%s/delete',
1923
	'path_labels' => array(
1924
		'$site' => '(int|string) Site ID or domain',
1925
		'$tag'  => '(string) The tag slug',
1926
	),
1927
	'response_format' => array(
1928
		'slug'    => '(string) The slug of the deleted tag',
1929
		'success' => '(bool) Was the operation successful?',
1930
	),
1931
1932
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/tags/slug:$tag/delete',
1933
	'example_request_data' => array(
1934
		'headers' => array(
1935
			'authorization' => 'Bearer YOUR_API_TOKEN'
1936
		),
1937
	)
1938
) );
1939
1940
new WPCOM_JSON_API_List_Terms_Endpoint( array(
1941
	'description' => 'Get a list of a site\'s terms by taxonomy.',
1942
	'group'       => 'taxonomy',
1943
	'stat'        => 'terms',
1944
	'method'      => 'GET',
1945
	'path'        => '/sites/%s/taxonomies/%s/terms',
1946
	'path_labels' => array(
1947
		'$site'     => '(int|string) Site ID or domain',
1948
		'$taxonomy' => '(string) Taxonomy',
1949
	),
1950
	'query_parameters' => array(
1951
		'number'   => '(int=100) The number of terms to return. Limit: 1000.',
1952
		'offset'   => '(int=0) 0-indexed offset.',
1953
		'page'     => '(int) Return the Nth 1-indexed page of terms. Takes precedence over the <code>offset</code> parameter.',
1954
		'search'   => '(string) Limit response to include only terms whose names or slugs match the provided search query.',
1955
		'order'    => array(
1956
			'ASC'  => 'Return terms in ascending order.',
1957
			'DESC' => 'Return terms in descending order.',
1958
		),
1959
		'order_by' => array(
1960
			'name'  => 'Order by the name of each tag.',
1961
			'count' => 'Order by the number of posts in each tag.',
1962
		),
1963
	),
1964
	'response_format' => array(
1965
		'found' => '(int) The number of terms returned.',
1966
		'terms' => '(array) Array of tag objects.',
1967
	),
1968
	'example_request'  => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/taxonomies/post_tags/terms?number=5'
1969
) );
1970
1971
new WPCOM_JSON_API_Get_Term_Endpoint( array(
1972
	'description' => 'Get information about a single term.',
1973
	'group'       => 'taxonomy',
1974
	'stat'        => 'terms:1',
1975
	'method'      => 'GET',
1976
	'path'        => '/sites/%s/taxonomies/%s/terms/slug:%s',
1977
	'path_labels' => array(
1978
		'$site'     => '(int|string) Site ID or domain',
1979
		'$taxonomy' => '(string) Taxonomy',
1980
		'$slug'     => '(string) Term slug',
1981
	),
1982
	'response_format' => array(
1983
		'ID'          => '(int) The term ID.',
1984
		'name'        => '(string) The name of the term.',
1985
		'slug'        => '(string) The slug of the term.',
1986
		'description' => '(string) The description of the term.',
1987
		'post_count'  => '(int) The number of posts using this term.',
1988
		'parent'      => '(int) The parent ID for the term, if hierarchical.',
1989
	),
1990
	'example_request'  => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/taxonomies/post_tag/terms/slug:wordpresscom'
1991
) );
1992
1993
new WPCOM_JSON_API_Update_Term_Endpoint( array(
1994
	'description' => 'Create a new term.',
1995
	'group'       => 'taxonomy',
1996
	'stat'        => 'terms:new',
1997
	'method'      => 'POST',
1998
	'path'        => '/sites/%s/taxonomies/%s/terms/new',
1999
	'path_labels' => array(
2000
		'$site'     => '(int|string) Site ID or domain',
2001
		'$taxonomy' => '(string) Taxonomy',
2002
	),
2003
	'request_format' => array(
2004
		'name'        => '(string) Name of the term',
2005
		'description' => '(string) A description of the term',
2006
	),
2007
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/taxonomies/post_tag/terms/new',
2008
	'example_request_data' => array(
2009
		'headers' => array(
2010
			'authorization' => 'Bearer YOUR_API_TOKEN'
2011
		),
2012
		'body' => array(
2013
			'name' => 'Ribs & Chicken'
2014
		)
2015
	)
2016
) );
2017
2018
new WPCOM_JSON_API_Update_Term_Endpoint( array(
2019
	'description' => 'Edit a term.',
2020
	'group'       => 'taxonomy',
2021
	'stat'        => 'terms:1:POST',
2022
	'method'      => 'POST',
2023
	'path'        => '/sites/%s/taxonomies/%s/terms/slug:%s',
2024
	'path_labels' => array(
2025
		'$site'     => '(int|string) Site ID or domain',
2026
		'$taxonomy' => '(string) Taxonomy',
2027
		'$slug'     => '(string) The term slug',
2028
	),
2029
	'request_format' => array(
2030
		'name'        => '(string) Name of the term',
2031
		'description' => '(string) A description of the term',
2032
	),
2033
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/taxonomies/post_tag/terms/slug:testing-term',
2034
	'example_request_data' => array(
2035
		'headers' => array(
2036
			'authorization' => 'Bearer YOUR_API_TOKEN'
2037
		),
2038
		'body' => array(
2039
			'description' => 'The most delicious'
2040
		)
2041
	)
2042
) );
2043
2044
new WPCOM_JSON_API_Update_Term_Endpoint( array(
2045
	'description' => 'Delete a term.',
2046
	'group'       => 'taxonomy',
2047
	'stat'        => 'terms:1:delete',
2048
	'method'      => 'POST',
2049
	'path'        => '/sites/%s/taxonomies/%s/terms/slug:%s/delete',
2050
	'path_labels' => array(
2051
		'$site'     => '(int|string) Site ID or domain',
2052
		'$taxonomy' => '(string) Taxonomy',
2053
		'$slug'     => '(string) The term slug',
2054
	),
2055
	'response_format' => array(
2056
		'slug'    => '(string) The slug of the deleted term',
2057
		'success' => '(bool) Whether the operation was successful',
2058
	),
2059
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/taxonomies/post_tag/terms/slug:$term/delete',
2060
	'example_request_data' => array(
2061
		'headers' => array(
2062
			'authorization' => 'Bearer YOUR_API_TOKEN'
2063
		),
2064
	)
2065
) );
2066
2067
new WPCOM_JSON_API_List_Roles_Endpoint( array(
2068
	'description' => 'List the user roles of a site.',
2069
	'group'       => '__do_not_document',
2070
	'stat'        => 'roles:list',
2071
2072
	'method'      => 'GET',
2073
	'path'        => '/sites/%s/roles',
2074
	'path_labels' => array(
2075
		'$site' => '(int|string) Site ID or domain',
2076
	),
2077
2078
	'query_parameters' => array(
2079
	),
2080
2081
	'response_format' => array(
2082
		'roles'  => '(array:role) Array of role objects.',
2083
	),
2084
2085
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/roles',
2086
	'example_request_data' => array(
2087
		'headers' => array(
2088
			'authorization' => 'Bearer YOUR_API_TOKEN'
2089
		),
2090
	)
2091
) );
2092
2093
new WPCOM_JSON_API_List_Users_Endpoint( array(
2094
	'description' => 'List the users of a site.',
2095
	'group'       => 'users',
2096
	'stat'        => 'users:list',
2097
2098
	'method'      => 'GET',
2099
	'path'        => '/sites/%s/users',
2100
	'path_labels' => array(
2101
		'$site' => '(int|string) Site ID or domain',
2102
	),
2103
2104
	'query_parameters' => array(
2105
		'number'   => '(int=20) Limit the total number of authors returned.',
2106
		'offset'   => '(int=0) The first n authors to be skipped in the returned array.',
2107
		'order'    => array(
2108
			'DESC' => 'Return authors in descending order.',
2109
			'ASC'  => 'Return authors in ascending order.',
2110
		),
2111
		'order_by' => array(
2112
			'ID'            => 'Order by ID (default).',
2113
			'login'         => 'Order by username.',
2114
			'nicename'      => "Order by nicename.",
2115
			'email'         => 'Order by author email address.',
2116
			'url'           => 'Order by author URL.',
2117
			'registered'    => 'Order by registered date.',
2118
			'display_name'  => 'Order by display name.',
2119
			'post_count'    => 'Order by number of posts published.',
2120
		),
2121
		'authors_only'      => '(bool) Set to true to fetch authors only',
2122
		'type'              => "(string) Specify the post type to query authors for. Only works when combined with the `authors_only` flag. Defaults to 'post'. Post types besides post and page need to be whitelisted using the <code>rest_api_allowed_post_types</code> filter.",
2123
		'search'            => '(string) Find matching users.',
2124
		'search_columns'    => "(array) Specify which columns to check for matching users. Can be any of 'ID', 'user_login', 'user_email', 'user_url', 'user_nicename', and 'display_name'. Only works when combined with `search` parameter.",
2125
		'role'              => '(string) Specify a specific user role to fetch.'
2126
	),
2127
2128
	'response_format' => array(
2129
		'found'    => '(int) The total number of authors found that match the request (ignoring limits and offsets).',
2130
		'authors'  => '(array:author) Array of author objects.',
2131
	),
2132
2133
	'example_response' => '{
2134
		"found": 1,
2135
		"users": [
2136
			{
2137
				"ID": 78972699,
2138
				"login": "apiexamples",
2139
				"email": "[email protected]",
2140
				"name": "apiexamples",
2141
				"first_name": "",
2142
				"last_name": "",
2143
				"nice_name": "apiexamples",
2144
				"URL": "http://apiexamples.wordpress.com",
2145
				"avatar_URL": "https://1.gravatar.com/avatar/a2afb7b6c0e23e5d363d8612fb1bd5ad?s=96&d=identicon&r=G",
2146
				"profile_URL": "http://en.gravatar.com/apiexamples",
2147
				"site_ID": 82974409,
2148
				"roles": [
2149
					"administrator"
2150
				],
2151
				"is_super_admin": false
2152
			}
2153
		]
2154
	}',
2155
2156
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/users',
2157
	'example_request_data' => array(
2158
		'headers' => array(
2159
			'authorization' => 'Bearer YOUR_API_TOKEN'
2160
		),
2161
	)
2162
) );
2163
2164
new WPCOM_JSON_API_Update_User_Endpoint( array(
2165
	'description' => 'Deletes or removes a user of a site.',
2166
	'group'       => 'users',
2167
	'stat'        => 'users:delete',
2168
2169
	'method'      => 'POST',
2170
	'path'        => '/sites/%s/users/%d/delete',
2171
	'path_labels' => array(
2172
		'$site'       => '(int|string) The site ID or domain.',
2173
		'$user_ID'    => '(int) The user\'s ID'
2174
	),
2175
2176
	'request_format' => array(
2177
		'reassign' => '(int) An optional id of a user to reassign posts to.',
2178
	),
2179
2180
	'response_format' => array(
2181
		'success' => '(bool) Was the deletion of user successful?',
2182
	),
2183
2184
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/users/1/delete',
2185
	'example_request_data' => array(
2186
		'headers' => array(
2187
			'authorization' => 'Bearer YOUR_API_TOKEN'
2188
		),
2189
	)
2190
) );
2191
2192
new WPCOM_JSON_API_List_Invites_Endpoint( array(
2193
	'description' => 'List the invites of a site.',
2194
	'group'       => '__do_not_document',
2195
	'stat'        => 'invites:list',
2196
2197
	'method'      => 'GET',
2198
	'path'        => '/sites/%s/invites',
2199
	'path_labels' => array(
2200
		'$site' => '(int|string) Site ID or domain',
2201
	),
2202
2203
	'query_parameters' => array(
2204
		'number'   => '(int=25) Limit the total number of invites to be returned.',
2205
		'offset'   => '(int=0) The first n invites to be skipped in the returned array.',
2206
		'status'   => array(
2207
			'pending' => 'Return only pending invites.',
2208
			'all'     => 'Return all invites, pending and accepted, that have not been deleted.',
2209
		)
2210
	),
2211
2212
	'response_format' => array(
2213
		'found'   => '(int) The total number of invites found that match the request (ignoring limits and offsets).',
2214
		'invites' => '(array) Array of invites.',
2215
	),
2216
2217
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/invites',
2218
	'example_request_data' => array(
2219
		'headers' => array(
2220
			'authorization' => 'Bearer YOUR_API_TOKEN'
2221
		),
2222
	),
2223
) );
2224
2225
new WPCOM_JSON_API_Site_User_Endpoint( array(
2226
	'description' => 'Get details of a user of a site by ID.',
2227
	'group'       => '__do_not_document', //'users'
2228
	'stat'        => 'sites:1:user',
2229
	'method'      => 'GET',
2230
	'path'        => '/sites/%s/users/%d',
2231
	'path_labels' => array(
2232
		'$site'    => '(int|string) Site ID or domain',
2233
		'$user_id' => '(int) User ID',
2234
	),
2235
	'response_format' => WPCOM_JSON_API_Site_User_Endpoint::$user_format,
2236
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/30434183/user/23',
2237
	'example_request_data' => array(
2238
		'headers' => array(
2239
			'authorization' => 'Bearer YOUR_API_TOKEN'
2240
		),
2241
	),
2242
	'example_response'     => '{
2243
		"ID": 18342963,
2244
		"login": "binarysmash"
2245
		"email": false,
2246
		"name": "binarysmash",
2247
		"URL": "http:\/\/binarysmash.wordpress.com",
2248
		"avatar_URL": "http:\/\/0.gravatar.com\/avatar\/a178ebb1731d432338e6bb0158720fcc?s=96&d=identicon&r=G",
2249
		"profile_URL": "http:\/\/en.gravatar.com\/binarysmash",
2250
		"roles": [ "administrator" ]
2251
	}'
2252
) );
2253
2254
new WPCOM_JSON_API_Site_User_Endpoint( array(
2255
	'description' => 'Get details of a user of a site by login.',
2256
	'group'       => 'users',
2257
	'stat'        => 'sites:1:user',
2258
	'method'      => 'GET',
2259
	'path'        => '/sites/%s/users/login:%s',
2260
	'path_labels' => array(
2261
		'$site'    => '(int|string) The site ID or domain.',
2262
		'$user_id' => '(string) The user\'s login.',
2263
	),
2264
	'response_format' => WPCOM_JSON_API_Site_User_Endpoint::$user_format,
2265
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/30434183/user/login:binarysmash',
2266
	'example_request_data' => array(
2267
		'headers' => array(
2268
			'authorization' => 'Bearer YOUR_API_TOKEN'
2269
		),
2270
	),
2271
	'example_response'     => '{
2272
		"ID": 18342963,
2273
		"login": "binarysmash"
2274
		"email": false,
2275
		"name": "binarysmash",
2276
		"URL": "http:\/\/binarysmash.wordpress.com",
2277
		"avatar_URL": "http:\/\/0.gravatar.com\/avatar\/a178ebb1731d432338e6bb0158720fcc?s=96&d=identicon&r=G",
2278
		"profile_URL": "http:\/\/en.gravatar.com\/binarysmash",
2279
		"roles": [ "administrator" ]
2280
	}'
2281
) );
2282
2283
new WPCOM_JSON_API_Site_User_Endpoint( array(
2284
	'description' => 'Update details of a user of a site.',
2285
	'group'       => 'users',
2286
	'stat'        => 'sites:1:user',
2287
	'method'      => 'POST',
2288
	'path'        => '/sites/%s/users/%d',
2289
	'path_labels' => array(
2290
		'$site'    => '(int|string) The site ID or domain.',
2291
		'$user_id' => '(int) The user\'s ID.',
2292
	),
2293
	'request_format'  => WPCOM_JSON_API_Site_User_Endpoint::$user_format,
2294
	'response_format' => WPCOM_JSON_API_Site_User_Endpoint::$user_format,
2295
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/30434183/user/23',
2296
	'example_request_data' => array(
2297
		'headers' => array(
2298
			'authorization' => 'Bearer YOUR_API_TOKEN'
2299
		),
2300
		'body' => array(
2301
			'roles' => array(
2302
				array(
2303
					'administrator',
2304
				)
2305
			),
2306
			'first_name' => 'Rocco',
2307
			'last_name' => 'Tripaldi',
2308
		)
2309
	),
2310
	'example_response'     => '{
2311
		"ID": 18342963,
2312
		"login": "binarysmash"
2313
		"email": false,
2314
		"name": "binarysmash",
2315
		"URL": "http:\/\/binarysmash.wordpress.com",
2316
		"avatar_URL": "http:\/\/0.gravatar.com\/avatar\/a178ebb1731d432338e6bb0158720fcc?s=96&d=identicon&r=G",
2317
		"profile_URL": "http:\/\/en.gravatar.com\/binarysmash",
2318
		"roles": [ "administrator" ]
2319
	}'
2320
) );
2321
2322
new WPCOM_JSON_API_Update_Invites_Endpoint( array(
2323
	'description' => 'Delete an invite for a user to join a site.',
2324
	'group'       => '__do_not_document',
2325
	'stat'        => 'invites:1:delete',
2326
	'method'      => 'POST',
2327
	'path'        => '/sites/%s/invites/%s/delete',
2328
	'path_labels' => array(
2329
		'$site'      => '(int|string) Site ID or domain',
2330
		'$invite_id' => '(string) The ID of the invite'
2331
	),
2332
	'response_format' => array(
2333
		'invite_key' => '(string) Identifier for the deleted invite',
2334
		'deleted' => '(bool) Was the invitation removed?'
2335
	),
2336
2337
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/invites/123523562/delete',
2338
2339
	'example_request_data' => array(
2340
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2341
	),
2342
) );
2343
2344
new WPCOM_JSON_API_Update_Invites_Endpoint( array(
2345
	'description' => 'Resend invitation for a user to join a site.',
2346
	'group'       => '__do_not_document',
2347
	'stat'        => 'invites:1',
2348
	'method'      => 'POST',
2349
	'path'        => '/sites/%s/invites/%s/resend',
2350
	'path_labels' => array(
2351
		'$site'      => '(int|string) Site ID or domain',
2352
		'$invite_id' => '(string) The ID of the invite'
2353
	),
2354
	'response_format' => array(
2355
		'result' => '(bool) Was the invitation resent?'
2356
	),
2357
2358
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/invites/123523562',
2359
2360
	'example_request_data' => array(
2361
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2362
	),
2363
) );
2364
2365
new WPCOM_JSON_API_Site_Settings_Endpoint( array(
2366
	'description' => 'Get detailed settings information about a site.',
2367
	'group'	      => '__do_not_document',
2368
	'stat'        => 'sites:X',
2369
2370
	'method'      => 'GET',
2371
	'path'        => '/sites/%s/settings',
2372
	'path_labels' => array(
2373
		'$site' => '(int|string) Site ID or domain',
2374
	),
2375
2376
	'query_parameters' => array(
2377
		'context' => false,
2378
	),
2379
2380
	'response_format' => WPCOM_JSON_API_Site_Settings_Endpoint::$site_format,
2381
2382
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/settings?pretty=1',
2383
) );
2384
2385
new WPCOM_JSON_API_Site_Settings_Endpoint( array(
2386
	'description' => 'Update settings for a site.',
2387
	'group'       => '__do_not_document',
2388
	'stat'        => 'sites:X',
2389
2390
	'method'      => 'POST',
2391
	'path'        => '/sites/%s/settings',
2392
	'path_labels' => array(
2393
		'$site' => '(int|string) Site ID or domain',
2394
	),
2395
2396
	'request_format'  => array(
2397
		'blogname'                     => '(string) Blog name',
2398
		'blogdescription'              => '(string) Blog description',
2399
		'default_pingback_flag'        => '(bool) Notify blogs linked from article?',
2400
		'default_ping_status'          => '(bool) Allow link notifications from other blogs?',
2401
		'default_comment_status'       => '(bool) Allow comments on new articles?',
2402
		'blog_public'                  => '(string) Site visibility; -1: private, 0: discourage search engines, 1: allow search engines',
2403
		'jetpack_sync_non_public_post_stati' => '(bool) allow sync of post and pages with non-public posts stati',
2404
		'jetpack_relatedposts_enabled' => '(bool) Enable related posts?',
2405
		'jetpack_relatedposts_show_headline' => '(bool) Show headline in related posts?',
2406
		'jetpack_relatedposts_show_thumbnails' => '(bool) Show thumbnails in related posts?',
2407
		'jetpack_protect_whitelist'    => '(array) List of IP addresses to whitelist',
2408
		'infinite_scroll'              => '(bool) Support infinite scroll of posts?',
2409
		'default_category'             => '(int) Default post category',
2410
		'default_post_format'          => '(string) Default post format',
2411
		'require_name_email'           => '(bool) Require comment authors to fill out name and email?',
2412
		'comment_registration'         => '(bool) Require users to be registered and logged in to comment?',
2413
		'close_comments_for_old_posts' => '(bool) Automatically close comments on old posts?',
2414
		'close_comments_days_old'      => '(int) Age at which to close comments',
2415
		'thread_comments'              => '(bool) Enable threaded comments?',
2416
		'thread_comments_depth'        => '(int) Depth to thread comments',
2417
		'page_comments'                => '(bool) Break comments into pages?',
2418
		'comments_per_page'            => '(int) Number of comments to display per page',
2419
		'default_comments_page'        => '(string) newest|oldest Which page of comments to display first',
2420
		'comment_order'                => '(string) asc|desc Order to display comments within page',
2421
		'comments_notify'              => '(bool) Email me when someone comments?',
2422
		'moderation_notify'            => '(bool) Email me when a comment is helf for moderation?',
2423
		'social_notifications_like'    => '(bool) Email me when someone likes my post?',
2424
		'social_notifications_reblog'  => '(bool) Email me when someone reblogs my post?',
2425
		'social_notifications_subscribe' => '(bool) Email me when someone follows my blog?',
2426
		'comment_moderation'           => '(bool) Moderate comments for manual approval?',
2427
		'comment_whitelist'            => '(bool) Moderate comments unless author has a previously-approved comment?',
2428
		'comment_max_links'            => '(int) Moderate comments that contain X or more links',
2429
		'moderation_keys'              => '(string) Words or phrases that trigger comment moderation, one per line',
2430
		'blacklist_keys'               => '(string) Words or phrases that mark comment spam, one per line',
2431
		'lang_id'                      => '(int) ID for language blog is written in',
2432
		'wga'                          => '(array) Google Analytics Settings',
2433
		'disabled_likes'               => '(bool) Are likes globally disabled (they can still be turned on per post)?',
2434
		'disabled_reblogs'             => '(bool) Are reblogs disabled on posts?',
2435
		'jetpack_comment_likes_enabled' => '(bool) Are comment likes enabled for all comments?',
2436
		'sharing_button_style'         => '(string) Style to use for sharing buttons (icon-text, icon, text, or official)',
2437
		'sharing_label'                => '(string) Label to use for sharing buttons, e.g. "Share this:"',
2438
		'sharing_show'                 => '(string|array:string) Post type or array of types where sharing buttons are to be displayed',
2439
		'sharing_open_links'           => '(string) Link target for sharing buttons (same or new)',
2440
		'twitter_via'                  => '(string) Twitter username to include in tweets when people share using the Twitter button',
2441
		'jetpack-twitter-cards-site-tag' => '(string) The Twitter username of the owner of the site\'s domain.',
2442
		'eventbrite_api_token'         => '(int) The Keyring token ID for an Eventbrite token to associate with the site',
2443
		'holidaysnow'                  => '(bool) Enable snowfall on frontend of site?'
2444
	),
2445
2446
	'response_format' => array(
2447
		'updated' => '(array)'
2448
	),
2449
2450
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/settings?pretty=1',
2451
) );
2452
2453
/**
2454
 * Sharing Button Endpoints
2455
 */
2456
2457
new WPCOM_JSON_API_Get_Sharing_Buttons_Endpoint( array(
2458
	'description' => 'Get a list of a site\'s sharing buttons.',
2459
	'group'       => 'sharing',
2460
	'stat'        => 'sharing-buttons',
2461
	'method'      => 'GET',
2462
	'path'        => '/sites/%s/sharing-buttons/',
2463
	'path_labels' => array(
2464
		'$site' => '(int|string) Site ID or domain',
2465
	),
2466
	'query_parameters' => array(
2467
		'enabled_only' => '(bool) If true, only enabled sharing buttons are included in the response',
2468
		'visibility'   => '(string) The type of enabled sharing buttons to filter by, either "visible" or "hidden"',
2469
	),
2470
	'response_format' => array(
2471
		'found'           => '(int) The total number of sharing buttons found that match the request.',
2472
 		'sharing_buttons' => '(array:object) Array of sharing button objects',
2473
	),
2474
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/30434183/sharing-buttons/',
2475
	'example_request_data' => array(
2476
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2477
	),
2478
	'example_response' => '{
2479
	"found": 1,
2480
	"sharing_buttons": [
2481
		{
2482
			"ID": "facebook",
2483
			"name": "Facebook"
2484
			"shortname": "facebook",
2485
			"custom": false,
2486
			"enabled": true,
2487
			"visibility": "visible",
2488
			"genericon": "\\f204"
2489
		}
2490
	]
2491
}'
2492
) );
2493
2494
new WPCOM_JSON_API_Get_Sharing_Button_Endpoint( array(
2495
	'description' => 'Get information about a single sharing button.',
2496
	'group'       => '__do_not_document',
2497
	'stat'        => 'sharing-buttons:1',
2498
	'method'      => 'GET',
2499
	'path'        => '/sites/%s/sharing-buttons/%s',
2500
	'path_labels' => array(
2501
		'$site'      => '(int|string) Site ID or domain',
2502
		'$button_id' => '(string) The button ID',
2503
	),
2504
	'response_format' => array(
2505
		'ID'           => '(int) Sharing button ID',
2506
		'name'         => '(string) Sharing button name, used as a label on the button itself',
2507
		'shortname'    => '(string) A generated short name for the sharing button',
2508
		'URL'          => '(string) The URL pattern defined for a custom sharing button',
2509
		'icon'         => '(string) URL to the 16x16 icon defined for a custom sharing button',
2510
		'genericon'    => '(string) Icon character in Genericons icon set',
2511
		'custom'       => '(bool) Is the button a user-created custom sharing button?',
2512
		'enabled'      => '(bool) Is the button currently enabled for the site?',
2513
		'visibility'   => '(string) If enabled, the current visibility of the sharing button, either "visible" or "hidden"',
2514
	),
2515
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/sharing-buttons/facebook',
2516
	'example_request_data' => array(
2517
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2518
	),
2519
	'example_response' => '{
2520
	"ID": "facebook",
2521
	"name": "Facebook"
2522
	"shortname": "facebook",
2523
	"custom": false,
2524
	"enabled": true,
2525
	"visibility": "visible",
2526
	"genericon": "\\f204"
2527
}'
2528
) );
2529
2530
new WPCOM_JSON_API_Update_Sharing_Buttons_Endpoint( array(
2531
	'description' => 'Edit all sharing buttons for a site.',
2532
	'group'       => 'sharing',
2533
	'stat'        => 'sharing-buttons:X:POST',
2534
	'method'      => 'POST',
2535
	'path'        => '/sites/%s/sharing-buttons',
2536
	'path_labels' => array(
2537
		'$site'      => '(int|string) Site ID or domain',
2538
	),
2539
	'request_format' => array(
2540
		'sharing_buttons' => '(array:sharing_button) An array of sharing button objects',
2541
	),
2542
	'response_format' => array(
2543
		'success' => '(bool) Confirmation that all sharing buttons were updated as specified',
2544
		'updated' => '(array) An array of updated sharing buttons',
2545
	),
2546
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/sharing-buttons',
2547
	'example_request_data' => array(
2548
		'headers' => array(
2549
			'authorization' => 'Bearer YOUR_API_TOKEN',
2550
		),
2551
		'body' => array(
2552
			'sharing_buttons' => array(
2553
				array(
2554
					'ID'         => 'facebook',
2555
					'visibility' => 'hidden',
2556
				)
2557
			)
2558
		)
2559
	),
2560
	'example_response' => '{
2561
	"success": true,
2562
	"updated": [
2563
		{
2564
			"ID": "facebook"
2565
			"name": "Facebook"
2566
			"shortname": "facebook"
2567
			"custom": false
2568
			"enabled": true,
2569
			"visibility": "hidden",
2570
			"genericon": "\f204"
2571
		}
2572
	]
2573
}'
2574
) );
2575
2576
new WPCOM_JSON_API_Update_Sharing_Button_Endpoint( array(
2577
	'description' => 'Create a new custom sharing button.',
2578
	'group'       => '__do_not_document',
2579
	'stat'        => 'sharing-buttons:new',
2580
	'method'      => 'POST',
2581
	'path'        => '/sites/%s/sharing-buttons/new',
2582
	'path_labels' => array(
2583
		'$site' => '(int|string) Site ID or domain',
2584
	),
2585
	'request_format' => array(
2586
		'name'       => '(string) The name for your custom sharing button, used as a label on the button itself',
2587
		'URL'        => '(string) The URL to use for share links, including optional placeholders (%post_title%, %post_url%, %post_full_url%, %post_excerpt%, %post_tags%)',
2588
		'icon'       => '(string) The full URL to a 16x16 icon to display on the sharing button',
2589
		'enabled'    => '(bool) Is the button currently enabled for the site?',
2590
		'visibility' => '(string) If enabled, the visibility of the sharing button, either "visible" (default) or "hidden"',
2591
	),
2592
	'response_format' => array(
2593
		'ID'           => '(string) Sharing button ID',
2594
		'name'         => '(string) Sharing button name, used as a label on the button itself',
2595
		'shortname'    => '(string) A generated short name for the sharing button',
2596
		'URL'          => '(string) The URL pattern defined for a custom sharing button',
2597
		'icon'         => '(string) URL to the 16x16 icon defined for a custom sharing button',
2598
		'genericon'    => '(string) Icon character in Genericons icon set',
2599
		'custom'       => '(bool) Is the button a user-created custom sharing button?',
2600
		'enabled'      => '(bool) Is the button currently enabled for the site?',
2601
		'visibility'   => '(string) If enabled, the current visibility of the sharing button, either "visible" or "hidden"',
2602
	),
2603
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/sharing-buttons/new/',
2604
	'example_request_data' => array(
2605
		'headers' => array(
2606
			'authorization' => 'Bearer YOUR_API_TOKEN'
2607
		),
2608
		'body' => array(
2609
			'name'       => 'Custom',
2610
			'URL'        => 'https://www.wordpress.com/%post_name%',
2611
			'icon'       => 'https://en.wordpress.com/i/stats-icon.gif',
2612
			'enabled'    => true,
2613
			'visibility' => 'visible'
2614
		)
2615
	),
2616
	'example_response' => '{
2617
	"ID": "custom-123456789",
2618
	"name": "Custom"
2619
	"shortname": "ustom",
2620
	"url": "https://www.wordpress.com/%post_name%",
2621
	"icon": "https://en.wordpress.com/i/stats-icon.gif",
2622
	"custom": true,
2623
	"enabled": true,
2624
	"visibility": "visible"
2625
}'
2626
) );
2627
2628
new WPCOM_JSON_API_Update_Sharing_Button_Endpoint( array(
2629
	'description' => 'Edit a sharing button.',
2630
	'group'       => '__do_not_document',
2631
	'stat'        => 'sharing-buttons:1:POST',
2632
	'method'      => 'POST',
2633
	'path'        => '/sites/%s/sharing-buttons/%s',
2634
	'path_labels' => array(
2635
		'$site'      => '(int|string) Site ID or domain',
2636
		'$button_id' => '(string) The button ID',
2637
	),
2638
	'request_format' => array(
2639
		'name'       => '(string) Only if a custom sharing button, a new name used as a label on the button itself',
2640
		'URL'        => '(string) Only if a custom sharing button, the URL to use for share links, including optional placeholders (%post_title%, %post_url%, %post_full_url%, %post_excerpt%, %post_tags%)',
2641
		'icon'       => '(string) Only if a custom sharing button, the full URL to a 16x16 icon to display on the sharing button',
2642
		'enabled'    => '(bool) Is the button currently enabled for the site?',
2643
		'visibility' => '(string) If enabled, the visibility of the sharing button, either "visible" (default) or "hidden"',
2644
	),
2645
	'response_format' => array(
2646
		'ID'           => '(string) Sharing button ID',
2647
		'name'         => '(string) Sharing button name, used as a label on the button itself',
2648
		'shortname'    => '(string) A generated short name for the sharing button',
2649
		'URL'          => '(string) The URL pattern defined for a custom sharing button',
2650
		'icon'         => '(string) URL to the 16x16 icon defined for a custom sharing button',
2651
		'genericon'    => '(string) Icon character in Genericons icon set',
2652
		'custom'       => '(bool) Is the button a user-created custom sharing button?',
2653
		'enabled'      => '(bool) Is the button currently enabled for the site?',
2654
		'visibility'   => '(string) If enabled, the current visibility of the sharing button, either "visible" or "hidden"',
2655
	),
2656
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/sharing-buttons/custom-123456789/',
2657
	'example_request_data' => array(
2658
		'headers' => array(
2659
			'authorization' => 'Bearer YOUR_API_TOKEN'
2660
		),
2661
		'body' => array(
2662
			'enabled' => false,
2663
		)
2664
	),
2665
	'example_response' => '{
2666
	"ID": "custom-123456789",
2667
	"name": "Custom"
2668
	"shortname": "ustom",
2669
	"custom": true,
2670
	"enabled": false,
2671
	"icon": "https://en.wordpress.com/i/stats-icon.gif",
2672
	"url": "https://www.wordpress.com/%post_name%"
2673
}'
2674
) );
2675
2676
new WPCOM_JSON_API_Delete_Sharing_Button_Endpoint( array(
2677
	'description' => 'Delete a custom sharing button.',
2678
	'group'		  => '__do_not_document',
2679
	'stat'		  => 'sharing-buttons:1:delete',
2680
	'method'	  => 'POST',
2681
	'path'        => '/sites/%s/sharing-buttons/%s/delete',
2682
	'path_labels' => array(
2683
		'$site'      => '(int|string) Site ID or domain',
2684
		'$button_id' => '(string) The button ID',
2685
	),
2686
	'response_format' => array(
2687
		'ID'      => '(int) The ID of the deleted sharing button',
2688
		'success' => '(bool) Confirmation that the sharing button has been removed'
2689
	),
2690
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/sharing-buttons/custom-123456789/delete',
2691
	'example_request_data' => array(
2692
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2693
	),
2694
	'example_response' => '{
2695
	"ID": "custom-123456789",
2696
	"success": "true"
2697
}'
2698
) );
2699
2700
/*
2701
 * Custom CSS endpoints
2702
 */
2703
new WPCOM_JSON_API_Get_CustomCss_Endpoint( array (
2704
	'description'      => 'Retrieve custom-css data for a site.',
2705
	'group'            => '__do_not_document',
2706
	'stat'             => 'customcss:1:get',
2707
	'method'           => 'GET',
2708
	'min_version'      => '1.1',
2709
	'path'             => '/sites/%s/customcss',
2710
	'path_labels'      => array(
2711
		'$site' => '(string) Site ID or domain.',
2712
	),
2713
	'response_format'  => array(
2714
		'css' => '(string) The raw CSS.',
2715
		'preprocessor' => '(string) The name of the preprocessor if any.',
2716
		'add_to_existing' => '(bool) False to skip the existing styles.',
2717
	),
2718
	'example_request'  => 'https://public-api.wordpress.com/rest/v1.1/sites/12345678/customcss',
2719
	'example_response' => array(
2720
		array(
2721
			'css' => '.stie-title { color: #fff; }',
2722
			'preprocessor' => 'sass',
2723
			'add_to_existing' => 'true',
2724
		)
2725
	)
2726
) );
2727
2728
new WPCOM_JSON_API_Update_CustomCss_Endpoint( array (
2729
	'description'      => 'Set custom-css data for a site.',
2730
	'group'            => '__do_not_document',
2731
	'stat'             => 'customcss:1:update',
2732
	'method'           => 'POST',
2733
	'min_version'      => '1.1',
2734
	'path'             => '/sites/%s/customcss',
2735
	'path_labels'      => array(
2736
		'$site' => '(string) Site ID or domain.',
2737
	),
2738
	'request_format'  => array(
2739
		'css' => '(string) Optional. The raw CSS.',
2740
		'preprocessor' => '(string) Optional. The name of the preprocessor if any.',
2741
		'add_to_existing' => '(bool) Optional. False to skip the existing styles.',
2742
	),
2743
	'response_format'  => array(
2744
		'css' => '(string) The raw CSS.',
2745
		'preprocessor' => '(string) The name of the preprocessor if any.',
2746
		'add_to_existing' => '(bool) False to skip the existing styles.',
2747
	),
2748
	'example_request'  => 'https://public-api.wordpress.com/rest/v1.1/sites/12345678/customcss',
2749
	'example_request_data' => array(
2750
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2751
		'body' => array(
2752
			'css' => '.stie-title { color: #fff; }',
2753
			'preprocessor' => 'sass'
2754
		),
2755
	),
2756
	'example_response' => array(
2757
		array(
2758
			'css' => '.stie-title { color: #fff; }',
2759
			'preprocessor' => 'sass',
2760
			'add_to_existing' => 'true',
2761
		)
2762
	)
2763
) );
2764
2765
/*
2766
 * Custom Menus endpoints
2767
 */
2768
new WPCOM_JSON_API_Menus_New_Menu_Endpoint( array (
2769
	'method' => 'POST',
2770
	'description' => 'Create a new navigation menu.',
2771
	'group' => 'menus',
2772
	'stat' => 'menus:new-menu',
2773
	'path' => '/sites/%s/menus/new',
2774
	'path_labels' => array(
2775
		'$site' => '(int|string) Site ID or domain',
2776
	),
2777
	'request_format'  => array(
2778
		'name' => '(string) Name of menu',
2779
	),
2780
	'response_format' => array(
2781
		'id' => '(int) Newly created menu ID',
2782
	),
2783
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/menus/new',
2784
	'example_request_data' => array(
2785
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2786
		'body' => array(
2787
			'name' => 'Menu 1'
2788
		)
2789
	),
2790
) );
2791
2792
new WPCOM_JSON_API_Menus_Update_Menu_Endpoint( array (
2793
	'method' => 'POST',
2794
	'description' => 'Update a navigation menu.',
2795
	'group' => 'menus',
2796
	'stat' => 'menus:update-menu',
2797
	'path' => '/sites/%s/menus/%d',
2798
	'path_labels' => array(
2799
		'$site' => '(int|string) Site ID or domain',
2800
		'$menu_id' => '(int) Menu ID',
2801
	),
2802
	'request_format'  => array(
2803
		'name'  => '(string) Name of menu',
2804
		'items' => '(array) A list of menu item objects.
2805
			<br/><br/>
2806
			Item objects contain fields relating to that item, e.g. id, type, content_id,
2807
			but they can also contain other items objects - this nesting represents parents
2808
			and child items in the item tree.'
2809
	),
2810
	'response_format' => array(
2811
		'menu' => '(object) Updated menu object',
2812
	),
2813
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/menus/347757165',
2814
	'example_request_data' => array(
2815
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2816
		'body' => array(
2817
			'name' => 'Menu 1'
2818
		),
2819
	),
2820
) );
2821
2822
new WPCOM_JSON_API_Menus_List_Menus_Endpoint( array (
2823
	'method'=> 'GET',
2824
	'description' => 'Get a list of all navigation menus.',
2825
	'group' => 'menus',
2826
	'stat' => 'menus:list-menu',
2827
	'path' => '/sites/%s/menus',
2828
	'path_labels' => array(
2829
		'$site' => '(int|string) Site ID or domain',
2830
	),
2831
	'response_format' => array(
2832
		'menus' => '(array) A list of menu objects.<br/><br/>
2833
			A menu object contains a name, items, locations, etc.
2834
			Check the example response for the full structure.
2835
			<br/><br/>
2836
			Item objects contain fields relating to that item, e.g. id, type, content_id,
2837
			but they can also contain other items objects - this nesting represents parents
2838
			and child items in the item tree.',
2839
		'locations' => '(array) Locations where menus can be placed. List of objects, one per location.'
2840
	),
2841
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/menus',
2842
	'example_request_data' => array(
2843
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2844
	),
2845
) );
2846
2847
new WPCOM_JSON_API_Menus_Get_Menu_Endpoint( array (
2848
	'method'=> 'GET',
2849
	'description' => 'Get a single navigation menu.',
2850
	'group' => 'menus',
2851
	'stat' => 'menus:get-menu',
2852
	'path' => '/sites/%s/menus/%d',
2853
	'path_labels' => array(
2854
		'$site' => '(int|string) Site ID or domain',
2855
		'$menu_id' => '(int) Menu ID',
2856
	),
2857
	'response_format' => array(
2858
		'menu' => '(object) A menu object.<br/><br/>
2859
			A menu object contains a name, items, locations, etc.
2860
			Check the example response for the full structure.
2861
			<br/><br/>
2862
			Item objects contain fields relating to that item, e.g. id, type, content_id,
2863
			but they can also contain other items objects - this nesting represents parents
2864
			and child items in the item tree.'
2865
	),
2866
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/menus/347757165',
2867
	'example_request_data' => array(
2868
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2869
	),
2870
) );
2871
2872
new WPCOM_JSON_API_Menus_Delete_Menu_Endpoint( array (
2873
	'method' => 'POST',
2874
	'description' => 'Delete a navigation menu',
2875
	'group' => 'menus',
2876
	'stat' => 'menus:delete-menu',
2877
	'path' => '/sites/%s/menus/%d/delete',
2878
	'path_labels' => array(
2879
		'$site' => '(int|string) Site ID or domain',
2880
		'$menu_id' => '(int) Menu ID',
2881
	),
2882
	'response_format' => array(
2883
		'deleted' => '(bool) Has the menu been deleted?',
2884
	),
2885
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/menus/$menu_id/delete',
2886
	'example_request_data' => array(
2887
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2888
	),
2889
) );
2890