Completed
Push — fix/3252 ( 1548f3 )
by
unknown
23:39 queued 14:28
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-list-comments-endpoint.php' );
35
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-media-endpoint.php' );
36
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-posts-endpoint.php' );
37
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-roles-endpoint.php' );
38
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-users-endpoint.php' );
39
require_once( $json_endpoints_dir . 'class.wpcom-json-api-site-user-endpoint.php' );
40
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-comment-endpoint.php' );
41
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-media-endpoint.php' );
42
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-post-endpoint.php' );
43
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-taxonomy-endpoint.php' );
44
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-user-endpoint.php' );
45
require_once( $json_endpoints_dir . 'class.wpcom-json-api-upload-media-endpoint.php' );
46
require_once( $json_endpoints_dir . 'class.wpcom-json-api-site-settings-endpoint.php' );
47
require_once( $json_endpoints_dir . 'class.wpcom-json-api-sharing-buttons-endpoint.php' );
48
49
// **********
50
// v1.1
51
// **********
52
53
// Media
54
require_once( $json_endpoints_dir . 'class.wpcom-json-api-delete-media-v1-1-endpoint.php' );
55
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-media-v1-1-endpoint.php' );
56
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-media-v1-1-endpoint.php' );
57
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-media-v1-1-endpoint.php' );
58
require_once( $json_endpoints_dir . 'class.wpcom-json-api-upload-media-v1-1-endpoint.php' );
59
60
// Posts
61
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-post-v1-1-endpoint.php' );
62
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-posts-v1-1-endpoint.php' );
63
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-post-v1-1-endpoint.php' );
64
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-autosave-v1-1-endpoint.php' );
65
require_once( $json_endpoints_dir . 'class.wpcom-json-api-autosave-post-v1-1-endpoint.php' );
66
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-post-counts-v1-1-endpoint.php' );
67
68
// Custom Menus
69
require_once( $json_endpoints_dir . 'class.wpcom-json-api-menus-v1-1-endpoint.php' );
70
71
// Users
72
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-invites-endpoint.php' );
73
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-invites-endpoint.php' );
74
75
// Custom CSS
76
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-customcss.php' );
77
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-customcss.php' );
78
79
// **********
80
// v1.2
81
// **********
82
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-post-v1-2-endpoint.php' );
83
84
// Jetpack Only Endpoints
85
$json_jetpack_endpoints_dir = dirname( __FILE__ ) . '/json-endpoints/jetpack/';
86
87
// This files instantiates the endpoints
88
require_once( $json_jetpack_endpoints_dir . 'json-api-jetpack-endpoints.php' );
89
90
/*
91
 * Endpoint instantiations
92
 */
93
94
new WPCOM_JSON_API_GET_Site_Endpoint( array(
95
	'description' => 'Get information about a site.',
96
	'group'	      => 'sites',
97
	'stat'        => 'sites:X',
98
	'allowed_if_flagged' => true,
99
	'method'      => 'GET',
100
	'path'        => '/sites/%s',
101
	'path_labels' => array(
102
		'$site' => '(int|string) Site ID or domain',
103
	),
104
105
	'query_parameters' => array(
106
		'context' => false,
107
	),
108
109
	'response_format' => WPCOM_JSON_API_GET_Site_Endpoint::$site_format,
110
111
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/',
112
) );
113
114
new WPCOM_JSON_API_GET_Post_Counts_V1_1_Endpoint( array(
115
	'description'   => 'Get number of posts in the post type groups by post status',
116
	'group'         => '__do_not_document',
117
	'stat'          => 'sites:X:post-counts:X',
118
	'force'         => 'wpcom',
119
	'method'        => 'GET',
120
	'min_version'   => '1.1',
121
	'max_version'   => '1.2',
122
	'path'          => '/sites/%s/post-counts/%s',
123
	'path_labels'   => array(
124
		'$site'       => '(int|string) Site ID or domain',
125
		'$post_type'  => '(string) Post Type',
126
	),
127
128
	'query_parameters' => array(
129
		'context' => false,
130
		'author' => '(int) author ID',
131
	),
132
133
	'example_request' => 'https://public-api.wordpress.com/rest/v1.2/sites/en.blog.wordpress.com/post-counts/page',
134
135
	'response_format' => array(
136
		'counts' => array(
137
			'all' => '(array) Number of posts by any author in the post type grouped by post status',
138
			'mine' => '(array) Number of posts by the current user in the post type grouped by post status'
139
		)
140
	)
141
) );
142
143
144
new WPCOM_JSON_API_List_Post_Formats_Endpoint( array(
145
	'description' => 'Get a list of post formats supported by a site.',
146
	'group'       => '__do_not_document',
147
	'stat'        => 'sites:X:post-formats',
148
149
	'method'      => 'GET',
150
	'path'        => '/sites/%s/post-formats',
151
	'path_labels' => array(
152
		'$site' => '(int|string) Site ID or domain',
153
	),
154
155
	'query_parameters' => array(
156
		'context' => false,
157
	),
158
159
	'response_format' => array(
160
		'formats' => '(array) A list of supported post formats. id => label.',
161
	)
162
) );
163
164
new WPCOM_JSON_API_List_Page_Templates_Endpoint( array(
165
	'description' => 'Get a list of page templates supported by a site.',
166
	'group'       => 'sites',
167
	'stat'        => 'sites:X:post-templates',
168
169
	'method'      => 'GET',
170
	'path'        => '/sites/%s/page-templates',
171
	'path_labels' => array(
172
		'$site' => '(int|string) Site ID or domain',
173
	),
174
	'query_parameters' => array(
175
		'context' => false,
176
	),
177
	'response_format' => array(
178
		'templates' => '(array) A list of supported page templates. Contains label and file.',
179
	)
180
) );
181
182
new WPCOM_JSON_API_List_Post_Types_Endpoint( array (
183
	'description' => 'Get a list of post types available for a site.',
184
	'group'       => '__do_not_document',
185
	'stat'        => 'sites:X:post-types',
186
187
	'method'      => 'GET',
188
	'path'        => '/sites/%s/post-types',
189
	'path_labels' => array(
190
		'$site' => '(int|string) Site ID or domain',
191
	),
192
193
	'query_parameters' => array(
194
		'api_queryable' => '(bool) If true, only queryable post types are returned',
195
	),
196
197
	'response_format' => array(
198
		'found'      => '(int) The number of post types found',
199
		'post_types' => '(array) A list of available post types',
200
	)
201
) );
202
203
/*
204
 * Shortcode endpoints
205
 */
206
207
new WPCOM_JSON_API_List_Shortcodes_Endpoint( array(
208
	'description' => "Get a list of shortcodes available on a site. Note: The current user must have publishing access.",
209
	'group'       => 'sites',
210
	'stat'        => 'shortcodes',
211
	'method'      => 'GET',
212
	'path'        => '/sites/%s/shortcodes',
213
	'path_labels' => array(
214
		'$site'    => '(int|string) Site ID or domain',
215
	),
216
	'response_format' => array(
217
		'shortcodes' => '(array) A list of supported shortcodes by their handle.',
218
	),
219
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/shortcodes',
220
	'example_request_data' => array(
221
		'headers' => array(
222
			'authorization' => 'Bearer YOUR_API_TOKEN'
223
		),
224
	)
225
) );
226
227
new WPCOM_JSON_API_Render_Shortcode_Endpoint( array(
228
	'description' => "Get a rendered shortcode for a site. Note: The current user must have publishing access.",
229
	'group'       => 'sites',
230
	'stat'        => 'shortcodes:render',
231
	'method'      => 'GET',
232
	'path'        => '/sites/%s/shortcodes/render',
233
	'path_labels' => array(
234
		'$site'    => '(int|string) Site ID or domain',
235
	),
236
	'query_parameters' => array(
237
		'shortcode'     => '(string) The query-string encoded shortcode string to render. Required. Only accepts one at a time.',
238
	),
239
	'response_format' => array(
240
		'shortcode' => '(string) The shortcode that was passed in for rendering.',
241
		'result'    => '(html) The rendered HTML result of the shortcode.',
242
		'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.',
243
		'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.',
244
	),
245
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/shortcodes/render?shortcode=%5Bgallery%20ids%3D%22729%2C732%2C731%2C720%22%5D',
246
	'example_request_data' => array(
247
		'headers' => array(
248
			'authorization' => 'Bearer YOUR_API_TOKEN'
249
		),
250
	)
251
) );
252
253
/*
254
 * embed endpoints
255
 */
256
new WPCOM_JSON_API_List_Embeds_Endpoint( array(
257
	'description' => "Get a list of embeds available on a site. Note: The current user must have publishing access.",
258
	'group'       => 'sites',
259
	'stat'        => 'embeds',
260
	'method'      => 'GET',
261
	'path'        => '/sites/%s/embeds',
262
	'path_labels' => array(
263
		'$site'    => '(int|string) Site ID or domain',
264
	),
265
	'response_format' => array(
266
		'embeds' => '(array) A list of supported embeds by their regex pattern.',
267
	),
268
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/embeds',
269
	'example_request_data' => array(
270
		'headers' => array(
271
			'authorization' => 'Bearer YOUR_API_TOKEN'
272
		),
273
	)
274
) );
275
276
new WPCOM_JSON_API_Render_Embed_Endpoint( array(
277
	'description' => "Get a rendered embed for a site. Note: The current user must have publishing access.",
278
	'group'       => 'sites',
279
	'stat'        => 'embeds:render',
280
	'method'      => 'GET',
281
	'path'        => '/sites/%s/embeds/render',
282
	'path_labels' => array(
283
		'$site'    => '(int|string) Site ID or domain',
284
	),
285
	'query_parameters' => array(
286
		'embed_url'     => '(string) The query-string encoded embed URL to render. Required. Only accepts one at a time.',
287
	),
288
	'response_format' => array(
289
		'embed_url' => '(string) The embed_url that was passed in for rendering.',
290
		'result'    => '(html) The rendered HTML result of the embed.',
291
	),
292
	'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',
293
	'example_request_data' => array(
294
		'headers' => array(
295
			'authorization' => 'Bearer YOUR_API_TOKEN'
296
		),
297
	)
298
) );
299
300
new WPCOM_JSON_API_Render_Embed_Reversal_Endpoint( array(
301
	'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.",
302
	//'group'       => 'sites',
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

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