Completed
Push — update/unit-testing ( 26ccbe )
by
unknown
09:58
created

json-endpoints.php (2 issues)

Upgrade to new PHP Analysis Engine

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

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