Completed
Pull Request — master (#6478)
by Nabeel
17:28
created

json-endpoints.php (2 issues)

Upgrade to new PHP Analysis Engine

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

1
<?php
2
3
/*
4
 * Endpoint class definitions. Only instantiations should be in this file
5
 *   file ordering matters
6
 */
7
8
$json_endpoints_dir = dirname( __FILE__ ) . '/json-endpoints/';
9
10
//abstract endpoints
11
require_once( $json_endpoints_dir . 'class.wpcom-json-api-post-endpoint.php' );
12
require_once( $json_endpoints_dir . 'class.wpcom-json-api-post-v1-1-endpoint.php' ); // v1.1
13
require_once( $json_endpoints_dir . 'class.wpcom-json-api-comment-endpoint.php' );
14
require_once( $json_endpoints_dir . 'class.wpcom-json-api-taxonomy-endpoint.php' );
15
16
17
// **********
18
// v1
19
// **********
20
21
require_once( $json_endpoints_dir . 'class.wpcom-json-api-delete-media-endpoint.php' );
22
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-comment-endpoint.php' );
23
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-media-endpoint.php' );
24
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-post-endpoint.php' );
25
require_once( $json_endpoints_dir . 'class.wpcom-json-api-render-endpoint.php' );
26
require_once( $json_endpoints_dir . 'class.wpcom-json-api-render-shortcode-endpoint.php' );
27
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-shortcodes-endpoint.php' );
28
require_once( $json_endpoints_dir . 'class.wpcom-json-api-render-embed-reversal-endpoint.php' );
29
require_once( $json_endpoints_dir . 'class.wpcom-json-api-render-embed-endpoint.php' );
30
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-embeds-endpoint.php' );
31
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-site-endpoint.php' );
32
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-taxonomies-endpoint.php' );
33
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-taxonomy-endpoint.php' );
34
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-term-endpoint.php' );
35
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-comments-endpoint.php' );
36
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-media-endpoint.php' );
37
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-post-types-endpoint.php' );
38
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-post-type-taxonomies-endpoint.php' );
39
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-posts-endpoint.php' );
40
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-roles-endpoint.php' );
41
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-terms-endpoint.php' );
42
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-users-endpoint.php' );
43
require_once( $json_endpoints_dir . 'class.wpcom-json-api-site-user-endpoint.php' );
44
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-comment-endpoint.php' );
45
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-media-endpoint.php' );
46
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-post-endpoint.php' );
47
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-taxonomy-endpoint.php' );
48
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-term-endpoint.php' );
49
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-user-endpoint.php' );
50
require_once( $json_endpoints_dir . 'class.wpcom-json-api-upload-media-endpoint.php' );
51
require_once( $json_endpoints_dir . 'class.wpcom-json-api-site-settings-endpoint.php' );
52
require_once( $json_endpoints_dir . 'class.wpcom-json-api-sharing-buttons-endpoint.php' );
53
54
// **********
55
// v1.1
56
// **********
57
58
// Media
59
require_once( $json_endpoints_dir . 'class.wpcom-json-api-delete-media-v1-1-endpoint.php' );
60
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-media-v1-1-endpoint.php' );
61
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-media-v1-1-endpoint.php' );
62
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-media-v1-1-endpoint.php' );
63
require_once( $json_endpoints_dir . 'class.wpcom-json-api-upload-media-v1-1-endpoint.php' );
64
65
// Posts
66
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-post-v1-1-endpoint.php' );
67
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-posts-v1-1-endpoint.php' );
68
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-post-v1-1-endpoint.php' );
69
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-autosave-v1-1-endpoint.php' );
70
require_once( $json_endpoints_dir . 'class.wpcom-json-api-autosave-post-v1-1-endpoint.php' );
71
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-post-counts-v1-1-endpoint.php' );
72
73
// Custom Menus
74
require_once( $json_endpoints_dir . 'class.wpcom-json-api-menus-v1-1-endpoint.php' );
75
76
// Users
77
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-invites-endpoint.php' );
78
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-invites-endpoint.php' );
79
80
// Custom CSS
81
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-customcss.php' );
82
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-customcss.php' );
83
84
// **********
85
// v1.2
86
// **********
87
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-post-v1-2-endpoint.php' );
88
require_once( $json_endpoints_dir . 'class.wpcom-json-api-site-settings-v1-2-endpoint.php' );
89
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-site-v1-2-endpoint.php' );
90
91
// 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
		'meta'  => '(object) Meta data',
1214
	),
1215
1216
	'example_request'      => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/media',
1217
	'example_request_data' =>  array(
1218
		'headers' => array(
1219
			'authorization' => 'Bearer YOUR_API_TOKEN'
1220
		)
1221
	)
1222
) );
1223
1224
new WPCOM_JSON_API_Get_Media_Endpoint( array(
1225
	'description' => 'Get a single media item (by ID).',
1226
	'group'       => 'media',
1227
	'stat'        => 'media:1',
1228
	'method'      => 'GET',
1229
	'path'        => '/sites/%s/media/%d',
1230
	'deprecated'  => true,
1231
	'new_version' => '1.1',
1232
	'max_version' => '1',
1233
	'path_labels' => array(
1234
		'$site'    => '(int|string) Site ID or domain',
1235
		'$media_ID' => '(int) The ID of the media item',
1236
	),
1237
	'response_format' => array(
1238
		'id'    => '(int) The ID of the media item',
1239
		'date' =>  '(ISO 8601 datetime) The date the media was uploaded',
1240
		'parent'           => '(int) ID of the post this media is attached to',
1241
		'link'             => '(string) URL to the file',
1242
		'title'            => '(string) Filename',
1243
		'caption'          => '(string) User-provided caption of the file',
1244
		'description'      => '(string) Description of the file',
1245
		'metadata'         => '(array) Array of metadata about the file, such as Exif data or sizes',
1246
	),
1247
1248
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/media/934',
1249
	'example_request_data' =>  array(
1250
		'headers' => array(
1251
			'authorization' => 'Bearer YOUR_API_TOKEN'
1252
		)
1253
	)
1254
) );
1255
1256
new WPCOM_JSON_API_Get_Media_v1_1_Endpoint( array(
1257
	'description' => 'Get a single media item (by ID).',
1258
	'group'       => 'media',
1259
	'stat'        => 'media:1',
1260
	'min_version' => '1.1',
1261
	'max_version' => '1.1',
1262
	'method'      => 'GET',
1263
	'path'        => '/sites/%s/media/%d',
1264
	'path_labels' => array(
1265
		'$site'    => '(int|string) Site ID or domain',
1266
		'$media_ID' => '(int) The ID of the media item',
1267
	),
1268
	'response_format' => array(
1269
		'ID'               => '(int) The ID of the media item',
1270
		'date'             => '(ISO 8601 datetime) The date the media was uploaded',
1271
		'post_ID'          => '(int) ID of the post this media is attached to',
1272
		'author_ID'        => '(int) ID of the user who uploaded the media',
1273
		'URL'              => '(string) URL to the file',
1274
		'guid'             => '(string) Unique identifier',
1275
		'file'			   => '(string) Filename',
1276
		'extension'        => '(string) File extension',
1277
		'mime_type'        => '(string) File MIME type',
1278
		'title'            => '(string) Filename',
1279
		'caption'          => '(string) User-provided caption of the file',
1280
		'description'      => '(string) Description of the file',
1281
		'alt'              => '(string)  Alternative text for image files.',
1282
		'thumbnails'       => '(object) Media item thumbnail URL options',
1283
		'height'           => '(int) (Image & video only) Height of the media item',
1284
		'width'            => '(int) (Image & video only) Width of the media item',
1285
		'length'           => '(int) (Video & audio only) Duration of the media item, in seconds',
1286
		'exif'             => '(array) (Image & audio only) Exif (meta) information about the media item',
1287
		'videopress_guid'  => '(string) (Video only) VideoPress GUID of the video when uploaded on a blog with VideoPress',
1288
		'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.'
1289
	),
1290
1291
	'example_request'      => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/media/934',
1292
	'example_request_data' =>  array(
1293
		'headers' => array(
1294
			'authorization' => 'Bearer YOUR_API_TOKEN'
1295
		)
1296
	)
1297
) );
1298
1299
new WPCOM_JSON_API_Upload_Media_Endpoint( array(
1300
	'description' => 'Upload a new media item.',
1301
	'group'       => 'media',
1302
	'stat'        => 'media:new',
1303
	'method'      => 'POST',
1304
	'path'        => '/sites/%s/media/new',
1305
	'deprecated'  => true,
1306
	'new_version' => '1.1',
1307
	'max_version' => '1',
1308
	'path_labels' => array(
1309
		'$site' => '(int|string) Site ID or domain',
1310
	),
1311
1312
	'request_format' => array(
1313
		'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 />" .
1314
		                "<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>",
1315
		'media_urls' => "(array) An array of URLs to upload to the post."
1316
	),
1317
1318
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/media/new/',
1319
1320
	'response_format' => array(
1321
		'media' => '(array) Array of uploaded media',
1322
		'errors' => '(array) Array of error messages of uploading media failures'
1323
	),
1324
	'example_request_data' =>  array(
1325
		'headers' => array(
1326
			'authorization' => 'Bearer YOUR_API_TOKEN'
1327
		),
1328
		'body' => array(
1329
			'media_urls' => "https://s.w.org/about/images/logos/codeispoetry-rgb.png"
1330
		)
1331
	)
1332
) );
1333
1334
new WPCOM_JSON_API_Upload_Media_v1_1_Endpoint( array(
1335
	'description' => 'Upload a new piece of media.',
1336
	'group'       => 'media',
1337
	'stat'        => 'media:new',
1338
	'min_version' => '1.1',
1339
	'max_version' => '1.1',
1340
	'method'      => 'POST',
1341
	'path'        => '/sites/%s/media/new',
1342
	'path_labels' => array(
1343
		'$site' => '(int|string) Site ID or domain',
1344
	),
1345
1346
	'request_format' => array(
1347
		'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 />" .
1348
		                "<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>",
1349
		'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.",
1350
		'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 />" .
1351
		                 "<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>",
1352
	),
1353
1354
	'response_format' => array(
1355
		'media' => '(array) Array of uploaded media objects',
1356
		'errors' => '(array) Array of error messages of uploading media failures'
1357
	),
1358
1359
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/media/new',
1360
	'example_request_data' =>  array(
1361
		'headers' => array(
1362
			'authorization' => 'Bearer YOUR_API_TOKEN'
1363
		),
1364
		'body' => array(
1365
			'media_urls' => "https://s.w.org/about/images/logos/codeispoetry-rgb.png"
1366
		)
1367
	)
1368
) );
1369
1370
new WPCOM_JSON_API_Update_Media_Endpoint( array(
1371
	'description' => 'Edit basic information about a media item.',
1372
	'group'       => 'media',
1373
	'stat'        => 'media:1:POST',
1374
	'method'      => 'POST',
1375
	'path'        => '/sites/%s/media/%d',
1376
	'deprecated'  => true,
1377
	'new_version' => '1.1',
1378
	'path_labels' => array(
1379
		'$site'    => '(int|string) Site ID or domain',
1380
		'$media_ID' => '(int) The ID of the media item',
1381
	),
1382
1383
	'request_format' => array(
1384
		'title'       => '(string) The file name.',
1385
		'caption'     => '(string) File caption.',
1386
		'description' => '(HTML) Description of the file.',
1387
	),
1388
1389
	'response_format' => array(
1390
		'id'          => '(int) The ID of the media item',
1391
		'date'        =>  '(ISO 8601 datetime) The date the media was uploaded',
1392
		'parent'      => '(int) ID of the post this media is attached to',
1393
		'link'        => '(string) URL to the file',
1394
		'title'       => '(string) File name',
1395
		'caption'     => '(string) User provided caption of the file',
1396
		'description' => '(string) Description of the file',
1397
		'metadata'    => '(array) Array of metadata about the file, such as Exif data or sizes',
1398
	),
1399
	'example_request'      => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/media/446',
1400
	'example_request_data' =>  array(
1401
		'headers' => array(
1402
			'authorization' => 'Bearer YOUR_API_TOKEN'
1403
		),
1404
		'body' => array(
1405
			'title' => 'Updated Title'
1406
		)
1407
	)
1408
) );
1409
1410
new WPCOM_JSON_API_Update_Media_v1_1_Endpoint( array(
1411
	'description' => 'Edit basic information about a media item.',
1412
	'group'       => 'media',
1413
	'stat'        => 'media:1:POST',
1414
	'min_version' => '1.1',
1415
	'max_version' => '1.1',
1416
	'method'      => 'POST',
1417
	'path'        => '/sites/%s/media/%d',
1418
	'path_labels' => array(
1419
		'$site'    => '(int|string) Site ID or domain',
1420
		'$media_ID' => '(int) The ID of the media item',
1421
	),
1422
1423
	'request_format' => array(
1424
		'parent_id'   => '(int) ID of the post this media is attached to',
1425
		'title'       => '(string) The file name.',
1426
		'caption'     => '(string) File caption.',
1427
		'description' => '(HTML) Description of the file.',
1428
		'alt'         => "(string) Alternative text for image files.",
1429
		'artist'      => "(string) Audio Only. Artist metadata for the audio track.",
1430
		'album'       => "(string) Audio Only. Album metadata for the audio track.",
1431
	),
1432
1433
	'response_format' => array(
1434
		'ID'               => '(int) The ID of the media item',
1435
		'date'             => '(ISO 8601 datetime) The date the media was uploaded',
1436
		'post_ID'          => '(int) ID of the post this media is attached to',
1437
		'author_ID'        => '(int) ID of the user who uploaded the media',
1438
		'URL'              => '(string) URL to the file',
1439
		'guid'             => '(string) Unique identifier',
1440
		'file'			   => '(string) File name',
1441
		'extension'        => '(string) File extension',
1442
		'mime_type'        => '(string) File mime type',
1443
		'title'            => '(string) File name',
1444
		'caption'          => '(string) User provided caption of the file',
1445
		'description'      => '(string) Description of the file',
1446
		'alt'              => '(string)  Alternative text for image files.',
1447
		'thumbnails'       => '(object) Media item thumbnail URL options',
1448
		'height'           => '(int) (Image & video only) Height of the media item',
1449
		'width'            => '(int) (Image & video only) Width of the media item',
1450
		'length'           => '(int) (Video & audio only) Duration of the media item, in seconds',
1451
		'exif'             => '(array) (Image & audio only) Exif (meta) information about the media item',
1452
		'videopress_guid'  => '(string) (Video only) VideoPress GUID of the video when uploaded on a blog with VideoPress',
1453
		'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.'
1454
	),
1455
1456
	'example_request'      => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/media/446',
1457
	'example_request_data' =>  array(
1458
		'headers' => array(
1459
			'authorization' => 'Bearer YOUR_API_TOKEN'
1460
		),
1461
		'body' => array(
1462
			'title' => 'Updated Title'
1463
		)
1464
	)
1465
) );
1466
1467
1468
new WPCOM_JSON_API_Delete_Media_Endpoint( array(
1469
	'description' => 'Delete a piece of media.',
1470
	'group'       => 'media',
1471
	'stat'        => 'media:1:delete',
1472
	'method'      => 'POST',
1473
	'path'        => '/sites/%s/media/%d/delete',
1474
	'deprecated'  => true,
1475
	'new_version' => '1.1',
1476
	'max_version' => '1',
1477
	'path_labels' => array(
1478
		'$site'    => '(int|string) Site ID or domain',
1479
		'$media_ID' => '(int) The media ID',
1480
	),
1481
1482
	'response_format' => array(
1483
		'status' => '(string) Returns deleted if the media was successfully deleted',
1484
		'id'    => '(int) The ID of the media item',
1485
		'date' =>  '(ISO 8601 datetime) The date the media was uploaded',
1486
		'parent'           => '(int) ID of the post this media is attached to',
1487
		'link'             => '(string) URL to the file',
1488
		'title'            => '(string) File name',
1489
		'caption'          => '(string) User provided caption of the file',
1490
		'description'      => '(string) Description of the file',
1491
		'metadata'         => '(array) Misc array of information about the file, such as exif data or sizes',
1492
	),
1493
1494
	'example_request'      => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/media/$media_ID/delete',
1495
	'example_request_data' =>  array(
1496
		'headers' => array(
1497
			'authorization' => 'Bearer YOUR_API_TOKEN'
1498
		)
1499
	)
1500
) );
1501
1502
new WPCOM_JSON_API_Delete_Media_v1_1_Endpoint( array(
1503
	'description' => 'Delete a piece of media. Note: Media is deleted and not trashed.',
1504
	'group'       => 'media',
1505
	'stat'        => 'media:1:delete',
1506
	'min_version' => '1.1',
1507
	'max_version' => '1.1',
1508
	'method'      => 'POST',
1509
	'path'        => '/sites/%s/media/%d/delete',
1510
	'path_labels' => array(
1511
		'$site'    => '(int|string) Site ID or domain',
1512
		'$media_ID' => '(int) The media ID',
1513
	),
1514
1515
	'response_format' => array(
1516
		'status'           => '(string) Returns deleted if the media was successfully deleted',
1517
		'ID'               => '(int) The ID of the media item',
1518
		'date'             => '(ISO 8601 datetime) The date the media was uploaded',
1519
		'post_ID'          => '(int) ID of the post this media is attached to',
1520
		'author_ID'        => '(int) ID of the user who uploaded the media',
1521
		'URL'              => '(string) URL to the file',
1522
		'guid'             => '(string) Unique identifier',
1523
		'file'			   => '(string) File name',
1524
		'extension'        => '(string) File extension',
1525
		'mime_type'        => '(string) File mime type',
1526
		'title'            => '(string) File name',
1527
		'caption'          => '(string) User-provided caption of the file',
1528
		'description'      => '(string) Description of the file',
1529
		'alt'              => '(string)  Alternative text for image files.',
1530
		'thumbnails'       => '(object) Media item thumbnail URL options',
1531
		'height'           => '(int) (Image & video only) Height of the media item',
1532
		'width'            => '(int) (Image & video only) Width of the media item',
1533
		'length'           => '(int) (Video & audio only) Duration of the media item, in seconds',
1534
		'exif'             => '(array) (Image & audio only) Exif (meta) information about the media item',
1535
		'videopress_guid'  => '(string) (Video only) VideoPress GUID of the video when uploaded on a blog with VideoPress',
1536
		'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'
1537
	),
1538
1539
	'example_request'      => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/media/$media_ID/delete',
1540
	'example_request_data' =>  array(
1541
		'headers' => array(
1542
			'authorization' => 'Bearer YOUR_API_TOKEN'
1543
		)
1544
	)
1545
) );
1546
1547
/*
1548
 * Comment endpoints
1549
 */
1550
new WPCOM_JSON_API_List_Comments_Endpoint( array(
1551
	'description' => 'Get a list of recent comments.',
1552
	'group'       => 'comments',
1553
	'stat'        => 'comments',
1554
1555
	'method'      => 'GET',
1556
	'path'        => '/sites/%s/comments/',
1557
	'path_labels' => array(
1558
		'$site' => '(int|string) Site ID or domain',
1559
	),
1560
1561
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/comments/?number=2'
1562
) );
1563
1564
new WPCOM_JSON_API_List_Comments_Endpoint( array(
1565
	'description' => 'Get a list of recent comments on a post.',
1566
	'group'       => 'comments',
1567
	'stat'        => 'posts:1:replies',
1568
1569
	'method'      => 'GET',
1570
	'path'        => '/sites/%s/posts/%d/replies/',
1571
	'path_labels' => array(
1572
		'$site'    => '(int|string) Site ID or domain',
1573
		'$post_ID' => '(int) The post ID',
1574
	),
1575
1576
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/posts/7/replies/?number=2'
1577
) );
1578
1579
new WPCOM_JSON_API_Get_Comment_Endpoint( array(
1580
	'description' => 'Get a single comment.',
1581
	'group'       => 'comments',
1582
	'stat'        => 'comments:1',
1583
1584
	'method'      => 'GET',
1585
	'path'        => '/sites/%s/comments/%d',
1586
	'path_labels' => array(
1587
		'$site'       => '(int|string) Site ID or domain',
1588
		'$comment_ID' => '(int) The comment ID'
1589
	),
1590
1591
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/comments/147564'
1592
) );
1593
1594
new WPCOM_JSON_API_Update_Comment_Endpoint( array(
1595
	'description' => 'Create a comment on a post.',
1596
	'group'       => 'comments',
1597
	'stat'        => 'posts:1:replies:new',
1598
1599
	'method'      => 'POST',
1600
	'path'        => '/sites/%s/posts/%d/replies/new',
1601
	'path_labels' => array(
1602
		'$site'    => '(int|string) Site ID or domain',
1603
		'$post_ID' => '(int) The post ID'
1604
	),
1605
1606
	'request_format' => array(
1607
		// explicitly document all input
1608
		'content'   => '(HTML) The comment text.',
1609
//		@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...
1610
//		'author'    => '(author object) The author of the comment.',
1611
	),
1612
1613
	'pass_wpcom_user_details' => true,
1614
1615
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/posts/843/replies/new/',
1616
	'example_request_data' =>  array(
1617
		'headers' => array(
1618
			'authorization' => 'Bearer YOUR_API_TOKEN'
1619
		),
1620
		'body' => array(
1621
			'content' => 'Your reply is very interesting. This is a reply.'
1622
		)
1623
	)
1624
) );
1625
1626
new WPCOM_JSON_API_Update_Comment_Endpoint( array(
1627
	'description' => 'Create a comment as a reply to another comment.',
1628
	'group'       => 'comments',
1629
	'stat'        => 'comments:1:replies:new',
1630
1631
	'method'      => 'POST',
1632
	'path'        => '/sites/%s/comments/%d/replies/new',
1633
	'path_labels' => array(
1634
		'$site'       => '(int|string) Site ID or domain',
1635
		'$comment_ID' => '(int) The comment ID'
1636
	),
1637
1638
	'request_format' => array(
1639
		'content'   => '(HTML) The comment text.',
1640
//		@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...
1641
//		'author'    => '(author object) The author of the comment.',
1642
	),
1643
1644
	'pass_wpcom_user_details' => true,
1645
1646
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/comments/29/replies/new',
1647
	'example_request_data' => array(
1648
		'headers' => array(
1649
			'authorization' => 'Bearer YOUR_API_TOKEN'
1650
		),
1651
		'body' => array(
1652
			'content' => 'This reply is very interesting. This is editing a comment reply via the API.',
1653
		)
1654
	)
1655
) );
1656
1657
new WPCOM_JSON_API_Update_Comment_Endpoint( array(
1658
	'description' => 'Edit a comment.',
1659
	'group'       => 'comments',
1660
	'stat'        => 'comments:1:POST',
1661
1662
	'method'      => 'POST',
1663
	'path'        => '/sites/%s/comments/%d',
1664
	'path_labels' => array(
1665
		'$site'       => '(int|string) Site ID or domain',
1666
		'$comment_ID' => '(int) The comment ID'
1667
	),
1668
1669
	'request_format' => array(
1670
		'date'    => "(ISO 8601 datetime) The comment's creation time.",
1671
		'content' => '(HTML) The comment text.',
1672
		'status'  => array(
1673
			'approved'   => 'Approve the comment.',
1674
			'unapproved' => 'Remove the comment from public view and send it to the moderation queue.',
1675
			'spam'       => 'Mark the comment as spam.',
1676
			'unspam'     => 'Unmark the comment as spam. Will attempt to set it to the previous status.',
1677
			'trash'      => 'Send a comment to the trash if trashing is enabled (see constant: EMPTY_TRASH_DAYS).',
1678
			'untrash'    => 'Untrash a comment. Only works when the comment is in the trash.',
1679
		),
1680
	),
1681
1682
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/comments/29',
1683
	'example_request_data' => array(
1684
		'headers' => array(
1685
			'authorization' => 'Bearer YOUR_API_TOKEN'
1686
		),
1687
		'body' => array(
1688
			'content' => 'This reply is now edited via the API.',
1689
			'status'  => 'approved',
1690
		)
1691
	)
1692
) );
1693
1694
new WPCOM_JSON_API_Update_Comment_Endpoint( array(
1695
	'description' => 'Delete a comment.',
1696
	'group'       => 'comments',
1697
	'stat'        => 'comments:1:delete',
1698
1699
	'method'      => 'POST',
1700
	'path'        => '/sites/%s/comments/%d/delete',
1701
	'path_labels' => array(
1702
		'$site'       => '(int|string) Site ID or domain',
1703
		'$comment_ID' => '(int) The comment ID'
1704
	),
1705
1706
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/comments/$comment_ID/delete',
1707
	'example_request_data' => array(
1708
		'headers' => array(
1709
			'authorization' => 'Bearer YOUR_API_TOKEN'
1710
		)
1711
	)
1712
) );
1713
1714
/**
1715
 * Taxonomy Management Endpoints
1716
 */
1717
new WPCOM_JSON_API_Get_Taxonomy_Endpoint( array(
1718
	'description' => 'Get information about a single category.',
1719
	'group'       => 'taxonomy',
1720
	'stat'        => 'categories:1',
1721
1722
	'method'      => 'GET',
1723
	'path'        => '/sites/%s/categories/slug:%s',
1724
	'path_labels' => array(
1725
		'$site'     => '(int|string) Site ID or domain',
1726
		'$category' => '(string) The category slug'
1727
	),
1728
1729
	'example_request'  => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/categories/slug:community'
1730
) );
1731
1732
new WPCOM_JSON_API_Get_Taxonomies_Endpoint( array(
1733
	'description' => "Get a list of a site's categories.",
1734
	'group'       => 'taxonomy',
1735
	'stat'        => 'categories',
1736
	'method'      => 'GET',
1737
	'path'        => '/sites/%s/categories',
1738
	'path_labels' => array(
1739
		'$site'     => '(int|string) Site ID or domain'
1740
	),
1741
	'query_parameters' => array(
1742
		'number'   => '(int=100) The number of categories to return. Limit: 1000.',
1743
		'offset'   => '(int=0) 0-indexed offset.',
1744
		'page'     => '(int) Return the Nth 1-indexed page of categories. Takes precedence over the <code>offset</code> parameter.',
1745
		'search'   => '(string) Limit response to include only categories whose names or slugs match the provided search query.',
1746
		'order'    => array(
1747
			'ASC'  => 'Return categories in ascending order.',
1748
			'DESC' => 'Return categories in descending order.',
1749
		),
1750
		'order_by' => array(
1751
			'name'  => 'Order by the name of each category.',
1752
			'count' => 'Order by the number of posts in each category.',
1753
		),
1754
	),
1755
	'response_format' => array(
1756
		'found'      => '(int) The number of categories returned.',
1757
		'categories' => '(array) Array of category objects.',
1758
	),
1759
	'example_request'  => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/categories/?number=5'
1760
) );
1761
1762
new WPCOM_JSON_API_Get_Taxonomies_Endpoint( array(
1763
	'description' => "Get a list of a site's tags.",
1764
	'group'       => 'taxonomy',
1765
	'stat'        => 'tags',
1766
	'method'      => 'GET',
1767
	'path'        => '/sites/%s/tags',
1768
	'path_labels' => array(
1769
		'$site'     => '(int|string) Site ID or domain'
1770
	),
1771
	'query_parameters' => array(
1772
		'number'   => '(int=100) The number of tags to return. Limit: 1000.',
1773
		'offset'   => '(int=0) 0-indexed offset.',
1774
		'page'     => '(int) Return the Nth 1-indexed page of tags. Takes precedence over the <code>offset</code> parameter.',
1775
		'search'   => '(string) Limit response to include only tags whose names or slugs match the provided search query.',
1776
		'order'    => array(
1777
			'ASC'  => 'Return tags in ascending order.',
1778
			'DESC' => 'Return tags in descending order.',
1779
		),
1780
		'order_by' => array(
1781
			'name'  => 'Order by the name of each tag.',
1782
			'count' => 'Order by the number of posts in each tag.',
1783
		),
1784
	),
1785
	'response_format' => array(
1786
		'found'    => '(int) The number of tags returned.',
1787
		'tags'     => '(array) Array of tag objects.',
1788
	),
1789
	'example_request'  => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/tags/?number=5'
1790
) );
1791
1792
new WPCOM_JSON_API_Get_Taxonomy_Endpoint( array(
1793
	'description' => 'Get information about a single tag.',
1794
	'group'       => 'taxonomy',
1795
	'stat'        => 'tags:1',
1796
1797
	'method'      => 'GET',
1798
	'path'        => '/sites/%s/tags/slug:%s',
1799
	'path_labels' => array(
1800
		'$site' => '(int|string) Site ID or domain',
1801
		'$tag'  => '(string) The tag slug'
1802
	),
1803
1804
	'example_request'  => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/tags/slug:wordpresscom'
1805
) );
1806
1807
new WPCOM_JSON_API_Update_Taxonomy_Endpoint( array(
1808
	'description' => 'Create a new category.',
1809
	'group'       => 'taxonomy',
1810
	'stat'        => 'categories:new',
1811
1812
	'method'      => 'POST',
1813
	'path'        => '/sites/%s/categories/new',
1814
	'path_labels' => array(
1815
		'$site' => '(int|string) Site ID or domain',
1816
	),
1817
1818
	'request_format' => array(
1819
		'name'        => '(string) Name of the category',
1820
		'description' => '(string) A description of the category',
1821
		'parent'      => '(int) ID of the parent category',
1822
	),
1823
1824
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/categories/new/',
1825
	'example_request_data' => array(
1826
		'headers' => array(
1827
			'authorization' => 'Bearer YOUR_API_TOKEN'
1828
		),
1829
		'body' => array(
1830
			'name' => 'Puppies',
1831
		)
1832
	)
1833
) );
1834
1835
new WPCOM_JSON_API_Update_Taxonomy_Endpoint( array(
1836
	'description' => 'Create a new tag.',
1837
	'group'       => 'taxonomy',
1838
	'stat'        => 'tags:new',
1839
1840
	'method'      => 'POST',
1841
	'path'        => '/sites/%s/tags/new',
1842
	'path_labels' => array(
1843
		'$site' => '(int|string) Site ID or domain',
1844
	),
1845
1846
	'request_format' => array(
1847
		'name'        => '(string) Name of the tag',
1848
		'description' => '(string) A description of the tag',
1849
	),
1850
1851
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/tags/new/',
1852
	'example_request_data' => array(
1853
		'headers' => array(
1854
			'authorization' => 'Bearer YOUR_API_TOKEN'
1855
		),
1856
		'body' => array(
1857
			'name' => 'Kitties'
1858
		)
1859
	)
1860
) );
1861
1862
new WPCOM_JSON_API_Update_Taxonomy_Endpoint( array(
1863
	'description' => 'Edit a tag.',
1864
	'group'       => 'taxonomy',
1865
	'stat'        => 'tags:1:POST',
1866
1867
	'method'      => 'POST',
1868
	'path'        => '/sites/%s/tags/slug:%s',
1869
	'path_labels' => array(
1870
		'$site' => '(int|string) Site ID or domain',
1871
		'$tag'  => '(string) The tag slug',
1872
	),
1873
1874
	'request_format' => array(
1875
		'name'        => '(string) Name of the tag',
1876
		'description' => '(string) A description of the tag',
1877
	),
1878
1879
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/tags/slug:testing-tag',
1880
	'example_request_data' => array(
1881
		'headers' => array(
1882
			'authorization' => 'Bearer YOUR_API_TOKEN'
1883
		),
1884
		'body' => array(
1885
			'description' => 'Kitties are awesome!'
1886
		)
1887
	)
1888
) );
1889
1890
new WPCOM_JSON_API_Update_Taxonomy_Endpoint( array(
1891
	'description' => 'Edit a category.',
1892
	'group'       => 'taxonomy',
1893
	'stat'        => 'categories:1:POST',
1894
1895
	'method'      => 'POST',
1896
	'path'        => '/sites/%s/categories/slug:%s',
1897
	'path_labels' => array(
1898
		'$site'     => '(int|string) Site ID or domain',
1899
		'$category' => '(string) The category slug',
1900
	),
1901
1902
	'request_format' => array(
1903
		'name'        => '(string) Name of the category',
1904
		'description' => '(string) A description of the category',
1905
		'parent'      => '(int) ID of the parent category',
1906
	),
1907
1908
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/categories/slug:testing-category',
1909
	'example_request_data' => array(
1910
		'headers' => array(
1911
			'authorization' => 'Bearer YOUR_API_TOKEN'
1912
		),
1913
		'body' => array(
1914
			'description' => 'Puppies are great!'
1915
		)
1916
	)
1917
) );
1918
1919
new WPCOM_JSON_API_Update_Taxonomy_Endpoint( array(
1920
	'description' => 'Delete a category.',
1921
	'group'       => 'taxonomy',
1922
	'stat'        => 'categories:1:delete',
1923
1924
	'method'      => 'POST',
1925
	'path'        => '/sites/%s/categories/slug:%s/delete',
1926
	'path_labels' => array(
1927
		'$site'     => '(int|string) Site ID or domain',
1928
		'$category' => '(string) The category slug',
1929
	),
1930
	'response_format' => array(
1931
		'slug'    => '(string) The slug of the deleted category',
1932
		'success' => '(bool) Was the operation successful?',
1933
	),
1934
1935
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/categories/slug:$category/delete',
1936
	'example_request_data' => array(
1937
		'headers' => array(
1938
			'authorization' => 'Bearer YOUR_API_TOKEN'
1939
		),
1940
	)
1941
) );
1942
1943
new WPCOM_JSON_API_Update_Taxonomy_Endpoint( array(
1944
	'description' => 'Delete a tag.',
1945
	'group'       => 'taxonomy',
1946
	'stat'        => 'tags:1:delete',
1947
1948
	'method'      => 'POST',
1949
	'path'        => '/sites/%s/tags/slug:%s/delete',
1950
	'path_labels' => array(
1951
		'$site' => '(int|string) Site ID or domain',
1952
		'$tag'  => '(string) The tag slug',
1953
	),
1954
	'response_format' => array(
1955
		'slug'    => '(string) The slug of the deleted tag',
1956
		'success' => '(bool) Was the operation successful?',
1957
	),
1958
1959
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/tags/slug:$tag/delete',
1960
	'example_request_data' => array(
1961
		'headers' => array(
1962
			'authorization' => 'Bearer YOUR_API_TOKEN'
1963
		),
1964
	)
1965
) );
1966
1967
new WPCOM_JSON_API_List_Terms_Endpoint( array(
1968
	'description' => 'Get a list of a site\'s terms by taxonomy.',
1969
	'group'       => 'taxonomy',
1970
	'stat'        => 'terms',
1971
	'method'      => 'GET',
1972
	'path'        => '/sites/%s/taxonomies/%s/terms',
1973
	'path_labels' => array(
1974
		'$site'     => '(int|string) Site ID or domain',
1975
		'$taxonomy' => '(string) Taxonomy',
1976
	),
1977
	'query_parameters' => array(
1978
		'number'   => '(int=100) The number of terms to return. Limit: 1000.',
1979
		'offset'   => '(int=0) 0-indexed offset.',
1980
		'page'     => '(int) Return the Nth 1-indexed page of terms. Takes precedence over the <code>offset</code> parameter.',
1981
		'search'   => '(string) Limit response to include only terms whose names or slugs match the provided search query.',
1982
		'order'    => array(
1983
			'ASC'  => 'Return terms in ascending order.',
1984
			'DESC' => 'Return terms in descending order.',
1985
		),
1986
		'order_by' => array(
1987
			'name'  => 'Order by the name of each tag.',
1988
			'count' => 'Order by the number of posts in each tag.',
1989
		),
1990
	),
1991
	'response_format' => array(
1992
		'found' => '(int) The number of terms returned.',
1993
		'terms' => '(array) Array of tag objects.',
1994
	),
1995
	'example_request'  => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/taxonomies/post_tags/terms?number=5'
1996
) );
1997
1998
new WPCOM_JSON_API_Get_Term_Endpoint( array(
1999
	'description' => 'Get information about a single term.',
2000
	'group'       => 'taxonomy',
2001
	'stat'        => 'terms:1',
2002
	'method'      => 'GET',
2003
	'path'        => '/sites/%s/taxonomies/%s/terms/slug:%s',
2004
	'path_labels' => array(
2005
		'$site'     => '(int|string) Site ID or domain',
2006
		'$taxonomy' => '(string) Taxonomy',
2007
		'$slug'     => '(string) Term slug',
2008
	),
2009
	'response_format' => array(
2010
		'ID'          => '(int) The term ID.',
2011
		'name'        => '(string) The name of the term.',
2012
		'slug'        => '(string) The slug of the term.',
2013
		'description' => '(string) The description of the term.',
2014
		'post_count'  => '(int) The number of posts using this term.',
2015
		'parent'      => '(int) The parent ID for the term, if hierarchical.',
2016
	),
2017
	'example_request'  => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/taxonomies/post_tag/terms/slug:wordpresscom'
2018
) );
2019
2020
new WPCOM_JSON_API_Update_Term_Endpoint( array(
2021
	'description' => 'Create a new term.',
2022
	'group'       => 'taxonomy',
2023
	'stat'        => 'terms:new',
2024
	'method'      => 'POST',
2025
	'path'        => '/sites/%s/taxonomies/%s/terms/new',
2026
	'path_labels' => array(
2027
		'$site'     => '(int|string) Site ID or domain',
2028
		'$taxonomy' => '(string) Taxonomy',
2029
	),
2030
	'request_format' => array(
2031
		'name'        => '(string) Name of the term',
2032
		'description' => '(string) A description of the term',
2033
		'parent'      => '(int) The parent ID for the term, if hierarchical',
2034
	),
2035
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/taxonomies/post_tag/terms/new',
2036
	'example_request_data' => array(
2037
		'headers' => array(
2038
			'authorization' => 'Bearer YOUR_API_TOKEN'
2039
		),
2040
		'body' => array(
2041
			'name' => 'Ribs & Chicken'
2042
		)
2043
	)
2044
) );
2045
2046
new WPCOM_JSON_API_Update_Term_Endpoint( array(
2047
	'description' => 'Edit a term.',
2048
	'group'       => 'taxonomy',
2049
	'stat'        => 'terms:1:POST',
2050
	'method'      => 'POST',
2051
	'path'        => '/sites/%s/taxonomies/%s/terms/slug:%s',
2052
	'path_labels' => array(
2053
		'$site'     => '(int|string) Site ID or domain',
2054
		'$taxonomy' => '(string) Taxonomy',
2055
		'$slug'     => '(string) The term slug',
2056
	),
2057
	'request_format' => array(
2058
		'name'        => '(string) Name of the term',
2059
		'description' => '(string) A description of the term',
2060
		'parent'      => '(int) The parent ID for the term, if hierarchical',
2061
	),
2062
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/taxonomies/post_tag/terms/slug:testing-term',
2063
	'example_request_data' => array(
2064
		'headers' => array(
2065
			'authorization' => 'Bearer YOUR_API_TOKEN'
2066
		),
2067
		'body' => array(
2068
			'description' => 'The most delicious'
2069
		)
2070
	)
2071
) );
2072
2073
new WPCOM_JSON_API_Update_Term_Endpoint( array(
2074
	'description' => 'Delete a term.',
2075
	'group'       => 'taxonomy',
2076
	'stat'        => 'terms:1:delete',
2077
	'method'      => 'POST',
2078
	'path'        => '/sites/%s/taxonomies/%s/terms/slug:%s/delete',
2079
	'path_labels' => array(
2080
		'$site'     => '(int|string) Site ID or domain',
2081
		'$taxonomy' => '(string) Taxonomy',
2082
		'$slug'     => '(string) The term slug',
2083
	),
2084
	'response_format' => array(
2085
		'slug'    => '(string) The slug of the deleted term',
2086
		'success' => '(bool) Whether the operation was successful',
2087
	),
2088
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/taxonomies/post_tag/terms/slug:$term/delete',
2089
	'example_request_data' => array(
2090
		'headers' => array(
2091
			'authorization' => 'Bearer YOUR_API_TOKEN'
2092
		),
2093
	)
2094
) );
2095
2096
new WPCOM_JSON_API_List_Roles_Endpoint( array(
2097
	'description' => 'List the user roles of a site.',
2098
	'group'       => '__do_not_document',
2099
	'stat'        => 'roles:list',
2100
2101
	'method'      => 'GET',
2102
	'path'        => '/sites/%s/roles',
2103
	'path_labels' => array(
2104
		'$site' => '(int|string) Site ID or domain',
2105
	),
2106
2107
	'query_parameters' => array(
2108
	),
2109
2110
	'response_format' => array(
2111
		'roles'  => '(array:role) Array of role objects.',
2112
	),
2113
2114
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/roles',
2115
	'example_request_data' => array(
2116
		'headers' => array(
2117
			'authorization' => 'Bearer YOUR_API_TOKEN'
2118
		),
2119
	)
2120
) );
2121
2122
new WPCOM_JSON_API_List_Users_Endpoint( array(
2123
	'description' => 'List the users of a site.',
2124
	'group'       => 'users',
2125
	'stat'        => 'users:list',
2126
2127
	'method'      => 'GET',
2128
	'path'        => '/sites/%s/users',
2129
	'path_labels' => array(
2130
		'$site' => '(int|string) Site ID or domain',
2131
	),
2132
2133
	'query_parameters' => array(
2134
		'number'   => '(int=20) Limit the total number of authors returned.',
2135
		'offset'   => '(int=0) The first n authors to be skipped in the returned array.',
2136
		'order'    => array(
2137
			'DESC' => 'Return authors in descending order.',
2138
			'ASC'  => 'Return authors in ascending order.',
2139
		),
2140
		'order_by' => array(
2141
			'ID'            => 'Order by ID (default).',
2142
			'login'         => 'Order by username.',
2143
			'nicename'      => "Order by nicename.",
2144
			'email'         => 'Order by author email address.',
2145
			'url'           => 'Order by author URL.',
2146
			'registered'    => 'Order by registered date.',
2147
			'display_name'  => 'Order by display name.',
2148
			'post_count'    => 'Order by number of posts published.',
2149
		),
2150
		'authors_only'      => '(bool) Set to true to fetch authors only',
2151
		'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.",
2152
		'search'            => '(string) Find matching users.',
2153
		'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.",
2154
		'role'              => '(string) Specify a specific user role to fetch.'
2155
	),
2156
2157
	'response_format' => array(
2158
		'found'    => '(int) The total number of authors found that match the request (ignoring limits and offsets).',
2159
		'authors'  => '(array:author) Array of author objects.',
2160
	),
2161
2162
	'example_response' => '{
2163
		"found": 1,
2164
		"users": [
2165
			{
2166
				"ID": 78972699,
2167
				"login": "apiexamples",
2168
				"email": "[email protected]",
2169
				"name": "apiexamples",
2170
				"first_name": "",
2171
				"last_name": "",
2172
				"nice_name": "apiexamples",
2173
				"URL": "http://apiexamples.wordpress.com",
2174
				"avatar_URL": "https://1.gravatar.com/avatar/a2afb7b6c0e23e5d363d8612fb1bd5ad?s=96&d=identicon&r=G",
2175
				"profile_URL": "https://en.gravatar.com/apiexamples",
2176
				"site_ID": 82974409,
2177
				"roles": [
2178
					"administrator"
2179
				],
2180
				"is_super_admin": false
2181
			}
2182
		]
2183
	}',
2184
2185
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/users',
2186
	'example_request_data' => array(
2187
		'headers' => array(
2188
			'authorization' => 'Bearer YOUR_API_TOKEN'
2189
		),
2190
	)
2191
) );
2192
2193
new WPCOM_JSON_API_Update_User_Endpoint( array(
2194
	'description' => 'Deletes or removes a user of a site.',
2195
	'group'       => 'users',
2196
	'stat'        => 'users:delete',
2197
2198
	'method'      => 'POST',
2199
	'path'        => '/sites/%s/users/%d/delete',
2200
	'path_labels' => array(
2201
		'$site'       => '(int|string) The site ID or domain.',
2202
		'$user_ID'    => '(int) The user\'s ID'
2203
	),
2204
2205
	'request_format' => array(
2206
		'reassign' => '(int) An optional id of a user to reassign posts to.',
2207
	),
2208
2209
	'response_format' => array(
2210
		'success' => '(bool) Was the deletion of user successful?',
2211
	),
2212
2213
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/users/1/delete',
2214
	'example_request_data' => array(
2215
		'headers' => array(
2216
			'authorization' => 'Bearer YOUR_API_TOKEN'
2217
		),
2218
	)
2219
) );
2220
2221
new WPCOM_JSON_API_List_Invites_Endpoint( array(
2222
	'description' => 'List the invites of a site.',
2223
	'group'       => '__do_not_document',
2224
	'stat'        => 'invites:list',
2225
2226
	'method'      => 'GET',
2227
	'path'        => '/sites/%s/invites',
2228
	'path_labels' => array(
2229
		'$site' => '(int|string) Site ID or domain',
2230
	),
2231
2232
	'query_parameters' => array(
2233
		'number'   => '(int=25) Limit the total number of invites to be returned.',
2234
		'offset'   => '(int=0) The first n invites to be skipped in the returned array.',
2235
		'status'   => array(
2236
			'pending' => 'Return only pending invites.',
2237
			'all'     => 'Return all invites, pending and accepted, that have not been deleted.',
2238
		)
2239
	),
2240
2241
	'response_format' => array(
2242
		'found'   => '(int) The total number of invites found that match the request (ignoring limits and offsets).',
2243
		'invites' => '(array) Array of invites.',
2244
	),
2245
2246
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/invites',
2247
	'example_request_data' => array(
2248
		'headers' => array(
2249
			'authorization' => 'Bearer YOUR_API_TOKEN'
2250
		),
2251
	),
2252
) );
2253
2254
new WPCOM_JSON_API_Site_User_Endpoint( array(
2255
	'description' => 'Get details of a user of a site by ID.',
2256
	'group'       => '__do_not_document', //'users'
2257
	'stat'        => 'sites:1:user',
2258
	'method'      => 'GET',
2259
	'path'        => '/sites/%s/users/%d',
2260
	'path_labels' => array(
2261
		'$site'    => '(int|string) Site ID or domain',
2262
		'$user_id' => '(int) User ID',
2263
	),
2264
	'response_format' => WPCOM_JSON_API_Site_User_Endpoint::$user_format,
2265
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/30434183/user/23',
2266
	'example_request_data' => array(
2267
		'headers' => array(
2268
			'authorization' => 'Bearer YOUR_API_TOKEN'
2269
		),
2270
	),
2271
	'example_response'     => '{
2272
		"ID": 18342963,
2273
		"login": "binarysmash"
2274
		"email": false,
2275
		"name": "binarysmash",
2276
		"URL": "http:\/\/binarysmash.wordpress.com",
2277
		"avatar_URL": "http:\/\/0.gravatar.com\/avatar\/a178ebb1731d432338e6bb0158720fcc?s=96&d=identicon&r=G",
2278
		"profile_URL": "http:\/\/en.gravatar.com\/binarysmash",
2279
		"roles": [ "administrator" ]
2280
	}'
2281
) );
2282
2283
new WPCOM_JSON_API_Site_User_Endpoint( array(
2284
	'description' => 'Get details of a user of a site by login.',
2285
	'group'       => 'users',
2286
	'stat'        => 'sites:1:user',
2287
	'method'      => 'GET',
2288
	'path'        => '/sites/%s/users/login:%s',
2289
	'path_labels' => array(
2290
		'$site'    => '(int|string) The site ID or domain.',
2291
		'$user_id' => '(string) The user\'s login.',
2292
	),
2293
	'response_format' => WPCOM_JSON_API_Site_User_Endpoint::$user_format,
2294
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/30434183/user/login:binarysmash',
2295
	'example_request_data' => array(
2296
		'headers' => array(
2297
			'authorization' => 'Bearer YOUR_API_TOKEN'
2298
		),
2299
	),
2300
	'example_response'     => '{
2301
		"ID": 18342963,
2302
		"login": "binarysmash"
2303
		"email": false,
2304
		"name": "binarysmash",
2305
		"URL": "http:\/\/binarysmash.wordpress.com",
2306
		"avatar_URL": "http:\/\/0.gravatar.com\/avatar\/a178ebb1731d432338e6bb0158720fcc?s=96&d=identicon&r=G",
2307
		"profile_URL": "http:\/\/en.gravatar.com\/binarysmash",
2308
		"roles": [ "administrator" ]
2309
	}'
2310
) );
2311
2312
new WPCOM_JSON_API_Site_User_Endpoint( array(
2313
	'description' => 'Update details of a user of a site.',
2314
	'group'       => 'users',
2315
	'stat'        => 'sites:1:user',
2316
	'method'      => 'POST',
2317
	'path'        => '/sites/%s/users/%d',
2318
	'path_labels' => array(
2319
		'$site'    => '(int|string) The site ID or domain.',
2320
		'$user_id' => '(int) The user\'s ID.',
2321
	),
2322
	'request_format'  => WPCOM_JSON_API_Site_User_Endpoint::$user_format,
2323
	'response_format' => WPCOM_JSON_API_Site_User_Endpoint::$user_format,
2324
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/30434183/user/23',
2325
	'example_request_data' => array(
2326
		'headers' => array(
2327
			'authorization' => 'Bearer YOUR_API_TOKEN'
2328
		),
2329
		'body' => array(
2330
			'roles' => array(
2331
				array(
2332
					'administrator',
2333
				)
2334
			),
2335
			'first_name' => 'Rocco',
2336
			'last_name' => 'Tripaldi',
2337
		)
2338
	),
2339
	'example_response'     => '{
2340
		"ID": 18342963,
2341
		"login": "binarysmash"
2342
		"email": false,
2343
		"name": "binarysmash",
2344
		"URL": "http:\/\/binarysmash.wordpress.com",
2345
		"avatar_URL": "http:\/\/0.gravatar.com\/avatar\/a178ebb1731d432338e6bb0158720fcc?s=96&d=identicon&r=G",
2346
		"profile_URL": "http:\/\/en.gravatar.com\/binarysmash",
2347
		"roles": [ "administrator" ]
2348
	}'
2349
) );
2350
2351
new WPCOM_JSON_API_Update_Invites_Endpoint( array(
2352
	'description' => 'Delete an invite for a user to join a site.',
2353
	'group'       => '__do_not_document',
2354
	'stat'        => 'invites:1:delete',
2355
	'method'      => 'POST',
2356
	'path'        => '/sites/%s/invites/%s/delete',
2357
	'path_labels' => array(
2358
		'$site'      => '(int|string) Site ID or domain',
2359
		'$invite_id' => '(string) The ID of the invite'
2360
	),
2361
	'response_format' => array(
2362
		'invite_key' => '(string) Identifier for the deleted invite',
2363
		'deleted' => '(bool) Was the invitation removed?'
2364
	),
2365
2366
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/invites/123523562/delete',
2367
2368
	'example_request_data' => array(
2369
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2370
	),
2371
) );
2372
2373
new WPCOM_JSON_API_Update_Invites_Endpoint( array(
2374
	'description' => 'Resend invitation for a user to join a site.',
2375
	'group'       => '__do_not_document',
2376
	'stat'        => 'invites:1',
2377
	'method'      => 'POST',
2378
	'path'        => '/sites/%s/invites/%s/resend',
2379
	'path_labels' => array(
2380
		'$site'      => '(int|string) Site ID or domain',
2381
		'$invite_id' => '(string) The ID of the invite'
2382
	),
2383
	'response_format' => array(
2384
		'result' => '(bool) Was the invitation resent?'
2385
	),
2386
2387
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/invites/123523562',
2388
2389
	'example_request_data' => array(
2390
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2391
	),
2392
) );
2393
2394
new WPCOM_JSON_API_Site_Settings_Endpoint( array(
2395
	'description' => 'Get detailed settings information about a site.',
2396
	'group'	      => '__do_not_document',
2397
	'stat'        => 'sites:X',
2398
2399
	'method'      => 'GET',
2400
	'path'        => '/sites/%s/settings',
2401
	'path_labels' => array(
2402
		'$site' => '(int|string) Site ID or domain',
2403
	),
2404
2405
	'query_parameters' => array(
2406
		'context' => false,
2407
	),
2408
2409
	'response_format' => WPCOM_JSON_API_Site_Settings_Endpoint::$site_format,
2410
2411
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/settings?pretty=1',
2412
) );
2413
2414
new WPCOM_JSON_API_Site_Settings_V1_2_Endpoint( array(
2415
	'description' => 'Get detailed settings information about a site.',
2416
	'group'	      => '__do_not_document',
2417
	'stat'        => 'sites:X',
2418
	'min_version'   => '1.2',
2419
	'method'      => 'GET',
2420
	'path'        => '/sites/%s/settings',
2421
	'path_labels' => array(
2422
		'$site' => '(int|string) Site ID or domain',
2423
	),
2424
2425
	'query_parameters' => array(
2426
		'context' => false,
2427
	),
2428
2429
	'response_format' => WPCOM_JSON_API_Site_Settings_Endpoint::$site_format,
2430
2431
	'example_request' => 'https://public-api.wordpress.com/rest/v1.2/sites/en.blog.wordpress.com/settings?pretty=1',
2432
) );
2433
2434
new WPCOM_JSON_API_Site_Settings_Endpoint( array(
2435
	'description' => 'Update settings for a site.',
2436
	'group'       => '__do_not_document',
2437
	'stat'        => 'sites:X',
2438
2439
	'method'      => 'POST',
2440
	'path'        => '/sites/%s/settings',
2441
	'path_labels' => array(
2442
		'$site' => '(int|string) Site ID or domain',
2443
	),
2444
2445
	'request_format'  => array(
2446
		'blogname'                             => '(string) Blog name',
2447
		'blogdescription'                      => '(string) Blog description',
2448
		'default_pingback_flag'                => '(bool) Notify blogs linked from article?',
2449
		'default_ping_status'                  => '(bool) Allow link notifications from other blogs?',
2450
		'default_comment_status'               => '(bool) Allow comments on new articles?',
2451
		'blog_public'                          => '(string) Site visibility; -1: private, 0: discourage search engines, 1: allow search engines',
2452
		'jetpack_sync_non_public_post_stati'   => '(bool) allow sync of post and pages with non-public posts stati',
2453
		'jetpack_relatedposts_enabled'         => '(bool) Enable related posts?',
2454
		'jetpack_relatedposts_show_headline'   => '(bool) Show headline in related posts?',
2455
		'jetpack_relatedposts_show_thumbnails' => '(bool) Show thumbnails in related posts?',
2456
		'jetpack_protect_whitelist'            => '(array) List of IP addresses to whitelist',
2457
		'infinite_scroll'                      => '(bool) Support infinite scroll of posts?',
2458
		'default_category'                     => '(int) Default post category',
2459
		'default_post_format'                  => '(string) Default post format',
2460
		'require_name_email'                   => '(bool) Require comment authors to fill out name and email?',
2461
		'comment_registration'                 => '(bool) Require users to be registered and logged in to comment?',
2462
		'close_comments_for_old_posts'         => '(bool) Automatically close comments on old posts?',
2463
		'close_comments_days_old'              => '(int) Age at which to close comments',
2464
		'thread_comments'                      => '(bool) Enable threaded comments?',
2465
		'thread_comments_depth'                => '(int) Depth to thread comments',
2466
		'page_comments'                        => '(bool) Break comments into pages?',
2467
		'comments_per_page'                    => '(int) Number of comments to display per page',
2468
		'default_comments_page'                => '(string) newest|oldest Which page of comments to display first',
2469
		'comment_order'                        => '(string) asc|desc Order to display comments within page',
2470
		'comments_notify'                      => '(bool) Email me when someone comments?',
2471
		'moderation_notify'                    => '(bool) Email me when a comment is helf for moderation?',
2472
		'social_notifications_like'            => '(bool) Email me when someone likes my post?',
2473
		'social_notifications_reblog'          => '(bool) Email me when someone reblogs my post?',
2474
		'social_notifications_subscribe'       => '(bool) Email me when someone follows my blog?',
2475
		'comment_moderation'                   => '(bool) Moderate comments for manual approval?',
2476
		'comment_whitelist'                    => '(bool) Moderate comments unless author has a previously-approved comment?',
2477
		'comment_max_links'                    => '(int) Moderate comments that contain X or more links',
2478
		'moderation_keys'                      => '(string) Words or phrases that trigger comment moderation, one per line',
2479
		'blacklist_keys'                       => '(string) Words or phrases that mark comment spam, one per line',
2480
		'lang_id'                              => '(int) ID for language blog is written in',
2481
		'wga'                                  => '(array) Google Analytics Settings',
2482
		'disabled_likes'                       => '(bool) Are likes globally disabled (they can still be turned on per post)?',
2483
		'disabled_reblogs'                     => '(bool) Are reblogs disabled on posts?',
2484
		'jetpack_comment_likes_enabled'        => '(bool) Are comment likes enabled for all comments?',
2485
		'sharing_button_style'                 => '(string) Style to use for sharing buttons (icon-text, icon, text, or official)',
2486
		'sharing_label'                        => '(string) Label to use for sharing buttons, e.g. "Share this:"',
2487
		'sharing_show'                         => '(string|array:string) Post type or array of types where sharing buttons are to be displayed',
2488
		'sharing_open_links'                   => '(string) Link target for sharing buttons (same or new)',
2489
		'twitter_via'                          => '(string) Twitter username to include in tweets when people share using the Twitter button',
2490
		'jetpack-twitter-cards-site-tag'       => '(string) The Twitter username of the owner of the site\'s domain.',
2491
		'eventbrite_api_token'                 => '(int) The Keyring token ID for an Eventbrite token to associate with the site',
2492
		'holidaysnow'                          => '(bool) Enable snowfall on front end of site?',
2493
		'timezone_string'                      => '(string) PHP-compatible timezone string like \'UTC-5\'',
2494
		'gmt_offset'                           => '(int) Site offset from UTC in hours',
2495
		'date_format'                          => '(string) PHP Date-compatible date format',
2496
		'time_format'                          => '(string) PHP Date-compatible time format',
2497
		'start_of_week'                        => '(int) Starting day of week (0 = Sunday, 6 = Saturday)',
2498
		'jetpack_testimonial'                  => '(bool) Whether testimonial custom post type is enabled for the site',
2499
		'jetpack_testimonial_posts_per_page'   => '(int) Number of testimonials to show per page',
2500
		'jetpack_portfolio'                    => '(bool) Whether portfolio custom post type is enabled for the site',
2501
		'jetpack_portfolio_posts_per_page'     => '(int) Number of portfolio projects to show per page',
2502
		'site_icon'                            => '(int) Media attachment ID to use as site icon. Set to zero or an otherwise empty value to clear',
2503
		'verification_services_codes'          => '(array) Website verification codes. Allowed keys: google, pinterest, bing, yandex',
2504
		Jetpack_SEO_Utils::FRONT_PAGE_META_OPTION => '(string) The SEO meta description for the site.',
2505
		Jetpack_SEO_Titles::TITLE_FORMATS_OPTION  => '(array) SEO meta title formats. Allowed keys: front_page, posts, pages, groups, archives',
2506
		'api_cache'                            => '(bool) Turn on/off the Jetpack JSON API cache'
2507
2508
	),
2509
2510
	'response_format' => array(
2511
		'updated' => '(array)'
2512
	),
2513
2514
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/settings?pretty=1',
2515
) );
2516
2517
new WPCOM_JSON_API_Site_Settings_V1_2_Endpoint( array(
2518
	'description' => 'Update settings for a site.',
2519
	'group'       => '__do_not_document',
2520
	'stat'        => 'sites:X',
2521
	'min_version'   => '1.2',
2522
	'method'      => 'POST',
2523
	'path'        => '/sites/%s/settings',
2524
	'path_labels' => array(
2525
		'$site' => '(int|string) Site ID or domain',
2526
	),
2527
2528
	'request_format'  => array(
2529
		'blogname'                     => '(string) Blog name',
2530
		'blogdescription'              => '(string) Blog description',
2531
		'default_pingback_flag'        => '(bool) Notify blogs linked from article?',
2532
		'default_ping_status'          => '(bool) Allow link notifications from other blogs?',
2533
		'default_comment_status'       => '(bool) Allow comments on new articles?',
2534
		'blog_public'                  => '(string) Site visibility; -1: private, 0: discourage search engines, 1: allow search engines',
2535
		'jetpack_sync_non_public_post_stati' => '(bool) allow sync of post and pages with non-public posts stati',
2536
		'jetpack_relatedposts_enabled' => '(bool) Enable related posts?',
2537
		'jetpack_relatedposts_show_headline' => '(bool) Show headline in related posts?',
2538
		'jetpack_relatedposts_show_thumbnails' => '(bool) Show thumbnails in related posts?',
2539
		'jetpack_protect_whitelist'    => '(array) List of IP addresses to whitelist',
2540
		'infinite_scroll'              => '(bool) Support infinite scroll of posts?',
2541
		'default_category'             => '(int) Default post category',
2542
		'default_post_format'          => '(string) Default post format',
2543
		'require_name_email'           => '(bool) Require comment authors to fill out name and email?',
2544
		'comment_registration'         => '(bool) Require users to be registered and logged in to comment?',
2545
		'close_comments_for_old_posts' => '(bool) Automatically close comments on old posts?',
2546
		'close_comments_days_old'      => '(int) Age at which to close comments',
2547
		'thread_comments'              => '(bool) Enable threaded comments?',
2548
		'thread_comments_depth'        => '(int) Depth to thread comments',
2549
		'page_comments'                => '(bool) Break comments into pages?',
2550
		'comments_per_page'            => '(int) Number of comments to display per page',
2551
		'default_comments_page'        => '(string) newest|oldest Which page of comments to display first',
2552
		'comment_order'                => '(string) asc|desc Order to display comments within page',
2553
		'comments_notify'              => '(bool) Email me when someone comments?',
2554
		'moderation_notify'            => '(bool) Email me when a comment is helf for moderation?',
2555
		'social_notifications_like'    => '(bool) Email me when someone likes my post?',
2556
		'social_notifications_reblog'  => '(bool) Email me when someone reblogs my post?',
2557
		'social_notifications_subscribe' => '(bool) Email me when someone follows my blog?',
2558
		'comment_moderation'           => '(bool) Moderate comments for manual approval?',
2559
		'comment_whitelist'            => '(bool) Moderate comments unless author has a previously-approved comment?',
2560
		'comment_max_links'            => '(int) Moderate comments that contain X or more links',
2561
		'moderation_keys'              => '(string) Words or phrases that trigger comment moderation, one per line',
2562
		'blacklist_keys'               => '(string) Words or phrases that mark comment spam, one per line',
2563
		'lang_id'                      => '(int) ID for language blog is written in',
2564
		'locale'                       => '(string) locale code for language blog is written in',
2565
		'wga'                          => '(array) Google Analytics Settings',
2566
		'disabled_likes'               => '(bool) Are likes globally disabled (they can still be turned on per post)?',
2567
		'disabled_reblogs'             => '(bool) Are reblogs disabled on posts?',
2568
		'jetpack_comment_likes_enabled' => '(bool) Are comment likes enabled for all comments?',
2569
		'sharing_button_style'         => '(string) Style to use for sharing buttons (icon-text, icon, text, or official)',
2570
		'sharing_label'                => '(string) Label to use for sharing buttons, e.g. "Share this:"',
2571
		'sharing_show'                 => '(string|array:string) Post type or array of types where sharing buttons are to be displayed',
2572
		'sharing_open_links'           => '(string) Link target for sharing buttons (same or new)',
2573
		'twitter_via'                  => '(string) Twitter username to include in tweets when people share using the Twitter button',
2574
		'jetpack-twitter-cards-site-tag' => '(string) The Twitter username of the owner of the site\'s domain.',
2575
		'eventbrite_api_token'         => '(int) The Keyring token ID for an Eventbrite token to associate with the site',
2576
		'holidaysnow'                  => '(bool) Enable snowfall on front end of site?',
2577
		'timezone_string'              => '(string) PHP-compatible timezone string like \'UTC-5\'',
2578
		'gmt_offset'                   => '(int) Site offset from UTC in hours',
2579
		'date_format'                  => '(string) PHP Date-compatible date format',
2580
		'time_format'                  => '(string) PHP Date-compatible time format',
2581
		'start_of_week'                => '(int) Starting day of week (0 = Sunday, 6 = Saturday)',
2582
		'verification_services_codes'  => '(array) Website verification codes. Allowed keys: google, pinterest, bing, yandex',
2583
		Jetpack_SEO_Utils::FRONT_PAGE_META_OPTION => '(string) The SEO meta description for the site.',
2584
		Jetpack_SEO_Titles::TITLE_FORMATS_OPTION  => '(array) SEO meta title formats. Allowed keys: front_page, posts, pages, groups, archives',
2585
		'api_cache'                    => '(bool) Turn on/off the Jetpack JSON API cache'
2586
	),
2587
2588
	'response_format' => array(
2589
		'updated' => '(array)'
2590
	),
2591
2592
	'example_request' => 'https://public-api.wordpress.com/rest/v1.2/sites/en.blog.wordpress.com/settings?pretty=1',
2593
) );
2594
2595
/**
2596
 * Sharing Button Endpoints
2597
 */
2598
2599
new WPCOM_JSON_API_Get_Sharing_Buttons_Endpoint( array(
2600
	'description' => 'Get a list of a site\'s sharing buttons.',
2601
	'group'       => 'sharing',
2602
	'stat'        => 'sharing-buttons',
2603
	'method'      => 'GET',
2604
	'path'        => '/sites/%s/sharing-buttons/',
2605
	'path_labels' => array(
2606
		'$site' => '(int|string) Site ID or domain',
2607
	),
2608
	'query_parameters' => array(
2609
		'enabled_only' => '(bool) If true, only enabled sharing buttons are included in the response',
2610
		'visibility'   => '(string) The type of enabled sharing buttons to filter by, either "visible" or "hidden"',
2611
	),
2612
	'response_format' => array(
2613
		'found'           => '(int) The total number of sharing buttons found that match the request.',
2614
 		'sharing_buttons' => '(array:object) Array of sharing button objects',
2615
	),
2616
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/30434183/sharing-buttons/',
2617
	'example_request_data' => array(
2618
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2619
	),
2620
	'example_response' => '{
2621
	"found": 1,
2622
	"sharing_buttons": [
2623
		{
2624
			"ID": "facebook",
2625
			"name": "Facebook"
2626
			"shortname": "facebook",
2627
			"custom": false,
2628
			"enabled": true,
2629
			"visibility": "visible",
2630
			"genericon": "\\f204"
2631
		}
2632
	]
2633
}'
2634
) );
2635
2636
new WPCOM_JSON_API_Get_Sharing_Button_Endpoint( array(
2637
	'description' => 'Get information about a single sharing button.',
2638
	'group'       => '__do_not_document',
2639
	'stat'        => 'sharing-buttons:1',
2640
	'method'      => 'GET',
2641
	'path'        => '/sites/%s/sharing-buttons/%s',
2642
	'path_labels' => array(
2643
		'$site'      => '(int|string) Site ID or domain',
2644
		'$button_id' => '(string) The button ID',
2645
	),
2646
	'response_format' => array(
2647
		'ID'           => '(int) Sharing button ID',
2648
		'name'         => '(string) Sharing button name, used as a label on the button itself',
2649
		'shortname'    => '(string) A generated short name for the sharing button',
2650
		'URL'          => '(string) The URL pattern defined for a custom sharing button',
2651
		'icon'         => '(string) URL to the 16x16 icon defined for a custom sharing button',
2652
		'genericon'    => '(string) Icon character in Genericons icon set',
2653
		'custom'       => '(bool) Is the button a user-created custom sharing button?',
2654
		'enabled'      => '(bool) Is the button currently enabled for the site?',
2655
		'visibility'   => '(string) If enabled, the current visibility of the sharing button, either "visible" or "hidden"',
2656
	),
2657
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/sharing-buttons/facebook',
2658
	'example_request_data' => array(
2659
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2660
	),
2661
	'example_response' => '{
2662
	"ID": "facebook",
2663
	"name": "Facebook"
2664
	"shortname": "facebook",
2665
	"custom": false,
2666
	"enabled": true,
2667
	"visibility": "visible",
2668
	"genericon": "\\f204"
2669
}'
2670
) );
2671
2672
new WPCOM_JSON_API_Update_Sharing_Buttons_Endpoint( array(
2673
	'description' => 'Edit all sharing buttons for a site.',
2674
	'group'       => 'sharing',
2675
	'stat'        => 'sharing-buttons:X:POST',
2676
	'method'      => 'POST',
2677
	'path'        => '/sites/%s/sharing-buttons',
2678
	'path_labels' => array(
2679
		'$site'      => '(int|string) Site ID or domain',
2680
	),
2681
	'request_format' => array(
2682
		'sharing_buttons' => '(array:sharing_button) An array of sharing button objects',
2683
	),
2684
	'response_format' => array(
2685
		'success' => '(bool) Confirmation that all sharing buttons were updated as specified',
2686
		'updated' => '(array) An array of updated sharing buttons',
2687
	),
2688
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/sharing-buttons',
2689
	'example_request_data' => array(
2690
		'headers' => array(
2691
			'authorization' => 'Bearer YOUR_API_TOKEN',
2692
		),
2693
		'body' => array(
2694
			'sharing_buttons' => array(
2695
				array(
2696
					'ID'         => 'facebook',
2697
					'visibility' => 'hidden',
2698
				)
2699
			)
2700
		)
2701
	),
2702
	'example_response' => '{
2703
	"success": true,
2704
	"updated": [
2705
		{
2706
			"ID": "facebook"
2707
			"name": "Facebook"
2708
			"shortname": "facebook"
2709
			"custom": false
2710
			"enabled": true,
2711
			"visibility": "hidden",
2712
			"genericon": "\f204"
2713
		}
2714
	]
2715
}'
2716
) );
2717
2718
new WPCOM_JSON_API_Update_Sharing_Button_Endpoint( array(
2719
	'description' => 'Create a new custom sharing button.',
2720
	'group'       => '__do_not_document',
2721
	'stat'        => 'sharing-buttons:new',
2722
	'method'      => 'POST',
2723
	'path'        => '/sites/%s/sharing-buttons/new',
2724
	'path_labels' => array(
2725
		'$site' => '(int|string) Site ID or domain',
2726
	),
2727
	'request_format' => array(
2728
		'name'       => '(string) The name for your custom sharing button, used as a label on the button itself',
2729
		'URL'        => '(string) The URL to use for share links, including optional placeholders (%post_id%, %post_title%, %post_slug%, %post_url%, %post_full_url%, %post_excerpt%, %post_tags%, %home_url%)',
2730
		'icon'       => '(string) The full URL to a 16x16 icon to display on the sharing button',
2731
		'enabled'    => '(bool) Is the button currently enabled for the site?',
2732
		'visibility' => '(string) If enabled, the visibility of the sharing button, either "visible" (default) or "hidden"',
2733
	),
2734
	'response_format' => array(
2735
		'ID'           => '(string) Sharing button ID',
2736
		'name'         => '(string) Sharing button name, used as a label on the button itself',
2737
		'shortname'    => '(string) A generated short name for the sharing button',
2738
		'URL'          => '(string) The URL pattern defined for a custom sharing button',
2739
		'icon'         => '(string) URL to the 16x16 icon defined for a custom sharing button',
2740
		'genericon'    => '(string) Icon character in Genericons icon set',
2741
		'custom'       => '(bool) Is the button a user-created custom sharing button?',
2742
		'enabled'      => '(bool) Is the button currently enabled for the site?',
2743
		'visibility'   => '(string) If enabled, the current visibility of the sharing button, either "visible" or "hidden"',
2744
	),
2745
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/sharing-buttons/new/',
2746
	'example_request_data' => array(
2747
		'headers' => array(
2748
			'authorization' => 'Bearer YOUR_API_TOKEN'
2749
		),
2750
		'body' => array(
2751
			'name'       => 'Custom',
2752
			'URL'        => 'https://www.wordpress.com/%post_name%',
2753
			'icon'       => 'https://en.wordpress.com/i/stats-icon.gif',
2754
			'enabled'    => true,
2755
			'visibility' => 'visible'
2756
		)
2757
	),
2758
	'example_response' => '{
2759
	"ID": "custom-123456789",
2760
	"name": "Custom"
2761
	"shortname": "ustom",
2762
	"url": "https://www.wordpress.com/%post_name%",
2763
	"icon": "https://en.wordpress.com/i/stats-icon.gif",
2764
	"custom": true,
2765
	"enabled": true,
2766
	"visibility": "visible"
2767
}'
2768
) );
2769
2770
new WPCOM_JSON_API_Update_Sharing_Button_Endpoint( array(
2771
	'description' => 'Edit a sharing button.',
2772
	'group'       => '__do_not_document',
2773
	'stat'        => 'sharing-buttons:1:POST',
2774
	'method'      => 'POST',
2775
	'path'        => '/sites/%s/sharing-buttons/%s',
2776
	'path_labels' => array(
2777
		'$site'      => '(int|string) Site ID or domain',
2778
		'$button_id' => '(string) The button ID',
2779
	),
2780
	'request_format' => array(
2781
		'name'       => '(string) Only if a custom sharing button, a new name used as a label on the button itself',
2782
		'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%)',
2783
		'icon'       => '(string) Only if a custom sharing button, the full URL to a 16x16 icon to display on the sharing button',
2784
		'enabled'    => '(bool) Is the button currently enabled for the site?',
2785
		'visibility' => '(string) If enabled, the visibility of the sharing button, either "visible" (default) or "hidden"',
2786
	),
2787
	'response_format' => array(
2788
		'ID'           => '(string) Sharing button ID',
2789
		'name'         => '(string) Sharing button name, used as a label on the button itself',
2790
		'shortname'    => '(string) A generated short name for the sharing button',
2791
		'URL'          => '(string) The URL pattern defined for a custom sharing button',
2792
		'icon'         => '(string) URL to the 16x16 icon defined for a custom sharing button',
2793
		'genericon'    => '(string) Icon character in Genericons icon set',
2794
		'custom'       => '(bool) Is the button a user-created custom sharing button?',
2795
		'enabled'      => '(bool) Is the button currently enabled for the site?',
2796
		'visibility'   => '(string) If enabled, the current visibility of the sharing button, either "visible" or "hidden"',
2797
	),
2798
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/sharing-buttons/custom-123456789/',
2799
	'example_request_data' => array(
2800
		'headers' => array(
2801
			'authorization' => 'Bearer YOUR_API_TOKEN'
2802
		),
2803
		'body' => array(
2804
			'enabled' => false,
2805
		)
2806
	),
2807
	'example_response' => '{
2808
	"ID": "custom-123456789",
2809
	"name": "Custom"
2810
	"shortname": "ustom",
2811
	"custom": true,
2812
	"enabled": false,
2813
	"icon": "https://en.wordpress.com/i/stats-icon.gif",
2814
	"url": "https://www.wordpress.com/%post_name%"
2815
}'
2816
) );
2817
2818
new WPCOM_JSON_API_Delete_Sharing_Button_Endpoint( array(
2819
	'description' => 'Delete a custom sharing button.',
2820
	'group'		  => '__do_not_document',
2821
	'stat'		  => 'sharing-buttons:1:delete',
2822
	'method'	  => 'POST',
2823
	'path'        => '/sites/%s/sharing-buttons/%s/delete',
2824
	'path_labels' => array(
2825
		'$site'      => '(int|string) Site ID or domain',
2826
		'$button_id' => '(string) The button ID',
2827
	),
2828
	'response_format' => array(
2829
		'ID'      => '(int) The ID of the deleted sharing button',
2830
		'success' => '(bool) Confirmation that the sharing button has been removed'
2831
	),
2832
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/sharing-buttons/custom-123456789/delete',
2833
	'example_request_data' => array(
2834
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2835
	),
2836
	'example_response' => '{
2837
	"ID": "custom-123456789",
2838
	"success": "true"
2839
}'
2840
) );
2841
2842
/*
2843
 * Custom CSS endpoints
2844
 */
2845
new WPCOM_JSON_API_Get_CustomCss_Endpoint( array (
2846
	'description'      => 'Retrieve custom-css data for a site.',
2847
	'group'            => '__do_not_document',
2848
	'stat'             => 'customcss:1:get',
2849
	'method'           => 'GET',
2850
	'min_version'      => '1.1',
2851
	'path'             => '/sites/%s/customcss',
2852
	'path_labels'      => array(
2853
		'$site' => '(string) Site ID or domain.',
2854
	),
2855
	'response_format'  => array(
2856
		'css' => '(string) The raw CSS.',
2857
		'preprocessor' => '(string) The name of the preprocessor if any.',
2858
		'add_to_existing' => '(bool) False to skip the existing styles.',
2859
	),
2860
	'example_request'  => 'https://public-api.wordpress.com/rest/v1.1/sites/12345678/customcss',
2861
	'example_response' => array(
2862
		array(
2863
			'css' => '.stie-title { color: #fff; }',
2864
			'preprocessor' => 'sass',
2865
			'add_to_existing' => 'true',
2866
		)
2867
	)
2868
) );
2869
2870
new WPCOM_JSON_API_Update_CustomCss_Endpoint( array (
2871
	'description'      => 'Set custom-css data for a site.',
2872
	'group'            => '__do_not_document',
2873
	'stat'             => 'customcss:1:update',
2874
	'method'           => 'POST',
2875
	'min_version'      => '1.1',
2876
	'path'             => '/sites/%s/customcss',
2877
	'path_labels'      => array(
2878
		'$site' => '(string) Site ID or domain.',
2879
	),
2880
	'request_format'  => array(
2881
		'css' => '(string) Optional. The raw CSS.',
2882
		'preprocessor' => '(string) Optional. The name of the preprocessor if any.',
2883
		'add_to_existing' => '(bool) Optional. False to skip the existing styles.',
2884
	),
2885
	'response_format'  => array(
2886
		'css' => '(string) The raw CSS.',
2887
		'preprocessor' => '(string) The name of the preprocessor if any.',
2888
		'add_to_existing' => '(bool) False to skip the existing styles.',
2889
	),
2890
	'example_request'  => 'https://public-api.wordpress.com/rest/v1.1/sites/12345678/customcss',
2891
	'example_request_data' => array(
2892
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2893
		'body' => array(
2894
			'css' => '.stie-title { color: #fff; }',
2895
			'preprocessor' => 'sass'
2896
		),
2897
	),
2898
	'example_response' => array(
2899
		array(
2900
			'css' => '.stie-title { color: #fff; }',
2901
			'preprocessor' => 'sass',
2902
			'add_to_existing' => 'true',
2903
		)
2904
	)
2905
) );
2906
2907
/*
2908
 * Custom Menus endpoints
2909
 */
2910
new WPCOM_JSON_API_Menus_New_Menu_Endpoint( array (
2911
	'method' => 'POST',
2912
	'description' => 'Create a new navigation menu.',
2913
	'group' => 'menus',
2914
	'stat' => 'menus:new-menu',
2915
	'path' => '/sites/%s/menus/new',
2916
	'path_labels' => array(
2917
		'$site' => '(int|string) Site ID or domain',
2918
	),
2919
	'request_format'  => array(
2920
		'name' => '(string) Name of menu',
2921
	),
2922
	'response_format' => array(
2923
		'id' => '(int) Newly created menu ID',
2924
	),
2925
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/menus/new',
2926
	'example_request_data' => array(
2927
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2928
		'body' => array(
2929
			'name' => 'Menu 1'
2930
		)
2931
	),
2932
) );
2933
2934
new WPCOM_JSON_API_Menus_Update_Menu_Endpoint( array (
2935
	'method' => 'POST',
2936
	'description' => 'Update a navigation menu.',
2937
	'group' => 'menus',
2938
	'stat' => 'menus:update-menu',
2939
	'path' => '/sites/%s/menus/%d',
2940
	'path_labels' => array(
2941
		'$site' => '(int|string) Site ID or domain',
2942
		'$menu_id' => '(int) Menu ID',
2943
	),
2944
	'request_format'  => array(
2945
		'name'  => '(string) Name of menu',
2946
		'items' => '(array) A list of menu item objects.
2947
			<br/><br/>
2948
			Item objects contain fields relating to that item, e.g. id, type, content_id,
2949
			but they can also contain other items objects - this nesting represents parents
2950
			and child items in the item tree.'
2951
	),
2952
	'response_format' => array(
2953
		'menu' => '(object) Updated menu object',
2954
	),
2955
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/menus/347757165',
2956
	'example_request_data' => array(
2957
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2958
		'body' => array(
2959
			'name' => 'Menu 1'
2960
		),
2961
	),
2962
) );
2963
2964
new WPCOM_JSON_API_Menus_List_Menus_Endpoint( array (
2965
	'method'=> 'GET',
2966
	'description' => 'Get a list of all navigation menus.',
2967
	'group' => 'menus',
2968
	'stat' => 'menus:list-menu',
2969
	'path' => '/sites/%s/menus',
2970
	'path_labels' => array(
2971
		'$site' => '(int|string) Site ID or domain',
2972
	),
2973
	'response_format' => array(
2974
		'menus' => '(array) A list of menu objects.<br/><br/>
2975
			A menu object contains a name, items, locations, etc.
2976
			Check the example response for the full structure.
2977
			<br/><br/>
2978
			Item objects contain fields relating to that item, e.g. id, type, content_id,
2979
			but they can also contain other items objects - this nesting represents parents
2980
			and child items in the item tree.',
2981
		'locations' => '(array) Locations where menus can be placed. List of objects, one per location.'
2982
	),
2983
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/menus',
2984
	'example_request_data' => array(
2985
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2986
	),
2987
) );
2988
2989
new WPCOM_JSON_API_Menus_Get_Menu_Endpoint( array (
2990
	'method'=> 'GET',
2991
	'description' => 'Get a single navigation menu.',
2992
	'group' => 'menus',
2993
	'stat' => 'menus:get-menu',
2994
	'path' => '/sites/%s/menus/%d',
2995
	'path_labels' => array(
2996
		'$site' => '(int|string) Site ID or domain',
2997
		'$menu_id' => '(int) Menu ID',
2998
	),
2999
	'response_format' => array(
3000
		'menu' => '(object) A menu object.<br/><br/>
3001
			A menu object contains a name, items, locations, etc.
3002
			Check the example response for the full structure.
3003
			<br/><br/>
3004
			Item objects contain fields relating to that item, e.g. id, type, content_id,
3005
			but they can also contain other items objects - this nesting represents parents
3006
			and child items in the item tree.'
3007
	),
3008
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/menus/347757165',
3009
	'example_request_data' => array(
3010
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
3011
	),
3012
) );
3013
3014
new WPCOM_JSON_API_Menus_Delete_Menu_Endpoint( array (
3015
	'method' => 'POST',
3016
	'description' => 'Delete a navigation menu',
3017
	'group' => 'menus',
3018
	'stat' => 'menus:delete-menu',
3019
	'path' => '/sites/%s/menus/%d/delete',
3020
	'path_labels' => array(
3021
		'$site' => '(int|string) Site ID or domain',
3022
		'$menu_id' => '(int) Menu ID',
3023
	),
3024
	'response_format' => array(
3025
		'deleted' => '(bool) Has the menu been deleted?',
3026
	),
3027
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/menus/$menu_id/delete',
3028
	'example_request_data' => array(
3029
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
3030
	),
3031
) );
3032