Completed
Push — fix/gulp-env ( ec4107...cf0b47 )
by
unknown
133:51 queued 124:05
created

json-endpoints.php (1 issue)

Upgrade to new PHP Analysis Engine

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

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