Completed
Push — sync/json-endpoints-19apr2017 ( 4d1744 )
by
unknown
64:46 queued 53:25
created

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

Syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')'
Loading history...
2938
		'podcasting_archive'           => '(string) The post category, if any, used for publishing podcasts',
2939
	),
2940
2941
	'response_format' => array(
2942
		'updated' => '(array)'
2943
	),
2944
2945
	'example_request' => 'https://public-api.wordpress.com/rest/v1.2/sites/en.blog.wordpress.com/settings?pretty=1',
2946
) );
2947
2948
/**
2949
 * Sharing Button Endpoints
2950
 */
2951
2952
new WPCOM_JSON_API_Get_Sharing_Buttons_Endpoint( array(
2953
	'description' => 'Get a list of a site\'s sharing buttons.',
2954
	'group'       => 'sharing',
2955
	'stat'        => 'sharing-buttons',
2956
	'method'      => 'GET',
2957
	'path'        => '/sites/%s/sharing-buttons/',
2958
	'path_labels' => array(
2959
		'$site' => '(int|string) Site ID or domain',
2960
	),
2961
	'query_parameters' => array(
2962
		'enabled_only' => '(bool) If true, only enabled sharing buttons are included in the response',
2963
		'visibility'   => '(string) The type of enabled sharing buttons to filter by, either "visible" or "hidden"',
2964
	),
2965
	'response_format' => array(
2966
		'found'           => '(int) The total number of sharing buttons found that match the request.',
2967
 		'sharing_buttons' => '(array:object) Array of sharing button objects',
2968
	),
2969
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/30434183/sharing-buttons/',
2970
	'example_request_data' => array(
2971
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
2972
	),
2973
	'example_response' => '
2974
{
2975
    "found": 2,
2976
    "sharing_buttons": [
2977
        {
2978
            "ID": "twitter",
2979
            "name": "Twitter",
2980
            "shortname": "twitter",
2981
            "custom": false,
2982
            "enabled": true,
2983
            "visibility": "visible",
2984
            "genericon": "\\f202"
2985
        },
2986
        {
2987
            "ID": "facebook",
2988
            "name": "Facebook",
2989
            "shortname": "facebook",
2990
            "custom": false,
2991
            "enabled": true,
2992
            "visibility": "visible",
2993
            "genericon": "\\f203"
2994
        }
2995
    ]
2996
}'
2997
) );
2998
2999
new WPCOM_JSON_API_Get_Sharing_Button_Endpoint( array(
3000
	'description' => 'Get information about a single sharing button.',
3001
	'group'       => '__do_not_document',
3002
	'stat'        => 'sharing-buttons:1',
3003
	'method'      => 'GET',
3004
	'path'        => '/sites/%s/sharing-buttons/%s',
3005
	'path_labels' => array(
3006
		'$site'      => '(int|string) Site ID or domain',
3007
		'$button_id' => '(string) The button ID',
3008
	),
3009
	'response_format' => array(
3010
		'ID'           => '(int) Sharing button ID',
3011
		'name'         => '(string) Sharing button name, used as a label on the button itself',
3012
		'shortname'    => '(string) A generated short name for the sharing button',
3013
		'URL'          => '(string) The URL pattern defined for a custom sharing button',
3014
		'icon'         => '(string) URL to the 16x16 icon defined for a custom sharing button',
3015
		'genericon'    => '(string) Icon character in Genericons icon set',
3016
		'custom'       => '(bool) Is the button a user-created custom sharing button?',
3017
		'enabled'      => '(bool) Is the button currently enabled for the site?',
3018
		'visibility'   => '(string) If enabled, the current visibility of the sharing button, either "visible" or "hidden"',
3019
	),
3020
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/sharing-buttons/facebook',
3021
	'example_request_data' => array(
3022
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
3023
	),
3024
	'example_response' => '{
3025
	"ID": "facebook",
3026
	"name": "Facebook",
3027
	"shortname": "facebook",
3028
	"custom": false,
3029
	"enabled": true,
3030
	"visibility": "visible",
3031
	"genericon": "\\f203"
3032
}'
3033
) );
3034
3035
new WPCOM_JSON_API_Update_Sharing_Buttons_Endpoint( array(
3036
	'description' => 'Edit all sharing buttons for a site.',
3037
	'group'       => 'sharing',
3038
	'stat'        => 'sharing-buttons:X:POST',
3039
	'method'      => 'POST',
3040
	'path'        => '/sites/%s/sharing-buttons',
3041
	'path_labels' => array(
3042
		'$site'      => '(int|string) Site ID or domain',
3043
	),
3044
	'request_format' => array(
3045
		'sharing_buttons' => '(array:sharing_button) An array of sharing button objects',
3046
	),
3047
	'response_format' => array(
3048
		'success' => '(bool) Confirmation that all sharing buttons were updated as specified',
3049
		'updated' => '(array) An array of updated sharing buttons',
3050
	),
3051
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/sharing-buttons',
3052
	'example_request_data' => array(
3053
		'headers' => array(
3054
			'authorization' => 'Bearer YOUR_API_TOKEN',
3055
		),
3056
		'body' => array(
3057
			'sharing_buttons' => array(
3058
				array(
3059
					'ID'         => 'facebook',
3060
					'visibility' => 'hidden',
3061
				)
3062
			)
3063
		)
3064
	),
3065
	'example_response' => '{
3066
	"success": true,
3067
	"updated": [
3068
		{
3069
			"ID": "facebook",
3070
			"name": "Facebook",
3071
			"shortname": "facebook",
3072
			"custom": false,
3073
			"enabled": true,
3074
			"visibility": "hidden",
3075
			"genericon": "\\f204"
3076
		}
3077
	]
3078
}'
3079
) );
3080
3081
new WPCOM_JSON_API_Update_Sharing_Button_Endpoint( array(
3082
	'description' => 'Create a new custom sharing button.',
3083
	'group'       => '__do_not_document',
3084
	'stat'        => 'sharing-buttons:new',
3085
	'method'      => 'POST',
3086
	'path'        => '/sites/%s/sharing-buttons/new',
3087
	'path_labels' => array(
3088
		'$site' => '(int|string) Site ID or domain',
3089
	),
3090
	'request_format' => array(
3091
		'name'       => '(string) The name for your custom sharing button, used as a label on the button itself',
3092
		'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%)',
3093
		'icon'       => '(string) The full URL to a 16x16 icon to display on the sharing button',
3094
		'enabled'    => '(bool) Is the button currently enabled for the site?',
3095
		'visibility' => '(string) If enabled, the visibility of the sharing button, either "visible" (default) or "hidden"',
3096
	),
3097
	'response_format' => array(
3098
		'ID'           => '(string) Sharing button ID',
3099
		'name'         => '(string) Sharing button name, used as a label on the button itself',
3100
		'shortname'    => '(string) A generated short name for the sharing button',
3101
		'URL'          => '(string) The URL pattern defined for a custom sharing button',
3102
		'icon'         => '(string) URL to the 16x16 icon defined for a custom sharing button',
3103
		'genericon'    => '(string) Icon character in Genericons icon set',
3104
		'custom'       => '(bool) Is the button a user-created custom sharing button?',
3105
		'enabled'      => '(bool) Is the button currently enabled for the site?',
3106
		'visibility'   => '(string) If enabled, the current visibility of the sharing button, either "visible" or "hidden"',
3107
	),
3108
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/sharing-buttons/new/',
3109
	'example_request_data' => array(
3110
		'headers' => array(
3111
			'authorization' => 'Bearer YOUR_API_TOKEN'
3112
		),
3113
		'body' => array(
3114
			'name'       => 'Custom',
3115
			'URL'        => 'https://www.wordpress.com/%post_name%',
3116
			'icon'       => 'https://en.wordpress.com/i/stats-icon.gif',
3117
			'enabled'    => true,
3118
			'visibility' => 'visible'
3119
		)
3120
	),
3121
	'example_response' => '{
3122
	"ID": "custom-123456789",
3123
	"name": "Custom",
3124
	"shortname": "custom",
3125
	"url": "https://www.wordpress.com/%post_name%",
3126
	"icon": "https://en.wordpress.com/i/stats-icon.gif",
3127
	"custom": true,
3128
	"enabled": true,
3129
	"visibility": "visible"
3130
}'
3131
) );
3132
3133
new WPCOM_JSON_API_Update_Sharing_Button_Endpoint( array(
3134
	'description' => 'Edit a sharing button.',
3135
	'group'       => '__do_not_document',
3136
	'stat'        => 'sharing-buttons:1:POST',
3137
	'method'      => 'POST',
3138
	'path'        => '/sites/%s/sharing-buttons/%s',
3139
	'path_labels' => array(
3140
		'$site'      => '(int|string) Site ID or domain',
3141
		'$button_id' => '(string) The button ID',
3142
	),
3143
	'request_format' => array(
3144
		'name'       => '(string) Only if a custom sharing button, a new name used as a label on the button itself',
3145
		'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%)',
3146
		'icon'       => '(string) Only if a custom sharing button, the full URL to a 16x16 icon to display on the sharing button',
3147
		'enabled'    => '(bool) Is the button currently enabled for the site?',
3148
		'visibility' => '(string) If enabled, the visibility of the sharing button, either "visible" (default) or "hidden"',
3149
	),
3150
	'response_format' => array(
3151
		'ID'           => '(string) Sharing button ID',
3152
		'name'         => '(string) Sharing button name, used as a label on the button itself',
3153
		'shortname'    => '(string) A generated short name for the sharing button',
3154
		'URL'          => '(string) The URL pattern defined for a custom sharing button',
3155
		'icon'         => '(string) URL to the 16x16 icon defined for a custom sharing button',
3156
		'genericon'    => '(string) Icon character in Genericons icon set',
3157
		'custom'       => '(bool) Is the button a user-created custom sharing button?',
3158
		'enabled'      => '(bool) Is the button currently enabled for the site?',
3159
		'visibility'   => '(string) If enabled, the current visibility of the sharing button, either "visible" or "hidden"',
3160
	),
3161
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/sharing-buttons/custom-123456789/',
3162
	'example_request_data' => array(
3163
		'headers' => array(
3164
			'authorization' => 'Bearer YOUR_API_TOKEN'
3165
		),
3166
		'body' => array(
3167
			'enabled' => false,
3168
		)
3169
	),
3170
	'example_response' => '{
3171
	"ID": "custom-123456789",
3172
	"name": "Custom",
3173
	"shortname": "custom",
3174
	"custom": true,
3175
	"enabled": false,
3176
	"icon": "https://en.wordpress.com/i/stats-icon.gif",
3177
	"url": "https://www.wordpress.com/%post_name%"
3178
}'
3179
) );
3180
3181
new WPCOM_JSON_API_Delete_Sharing_Button_Endpoint( array(
3182
	'description' => 'Delete a custom sharing button.',
3183
	'group'		  => '__do_not_document',
3184
	'stat'		  => 'sharing-buttons:1:delete',
3185
	'method'	  => 'POST',
3186
	'path'        => '/sites/%s/sharing-buttons/%s/delete',
3187
	'path_labels' => array(
3188
		'$site'      => '(int|string) Site ID or domain',
3189
		'$button_id' => '(string) The button ID',
3190
	),
3191
	'response_format' => array(
3192
		'ID'      => '(int) The ID of the deleted sharing button',
3193
		'success' => '(bool) Confirmation that the sharing button has been removed'
3194
	),
3195
	'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/sharing-buttons/custom-123456789/delete',
3196
	'example_request_data' => array(
3197
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
3198
	),
3199
	'example_response' => '{
3200
	"ID": "custom-123456789",
3201
	"success": "true"
3202
}'
3203
) );
3204
3205
/*
3206
 * Custom CSS endpoints
3207
 */
3208
new WPCOM_JSON_API_Get_CustomCss_Endpoint( array (
3209
	'description'      => 'Retrieve custom-css data for a site.',
3210
	'group'            => '__do_not_document',
3211
	'stat'             => 'customcss:1:get',
3212
	'method'           => 'GET',
3213
	'min_version'      => '1.1',
3214
	'path'             => '/sites/%s/customcss',
3215
	'path_labels'      => array(
3216
		'$site' => '(string) Site ID or domain.',
3217
	),
3218
	'response_format'  => array(
3219
		'css' => '(string) The raw CSS.',
3220
		'preprocessor' => '(string) The name of the preprocessor if any.',
3221
		'add_to_existing' => '(bool) False to skip the existing styles.',
3222
	),
3223
	'example_request'  => 'https://public-api.wordpress.com/rest/v1.1/sites/12345678/customcss',
3224
	'example_response' => '
3225
	{
3226
		"css": ".site-title { color: #fff; }",
3227
		"preprocessor": "sass",
3228
		"add_to_existing": "true"
3229
	}'
3230
) );
3231
3232
new WPCOM_JSON_API_Update_CustomCss_Endpoint( array (
3233
	'description'      => 'Set custom-css data for a site.',
3234
	'group'            => '__do_not_document',
3235
	'stat'             => 'customcss:1:update',
3236
	'method'           => 'POST',
3237
	'min_version'      => '1.1',
3238
	'path'             => '/sites/%s/customcss',
3239
	'path_labels'      => array(
3240
		'$site' => '(string) Site ID or domain.',
3241
	),
3242
	'request_format'  => array(
3243
		'css' => '(string) Optional. The raw CSS.',
3244
		'preprocessor' => '(string) Optional. The name of the preprocessor if any.',
3245
		'add_to_existing' => '(bool) Optional. False to skip the existing styles.',
3246
	),
3247
	'response_format'  => array(
3248
		'css' => '(string) The raw CSS.',
3249
		'preprocessor' => '(string) The name of the preprocessor if any.',
3250
		'add_to_existing' => '(bool) False to skip the existing styles.',
3251
	),
3252
	'example_request'  => 'https://public-api.wordpress.com/rest/v1.1/sites/12345678/customcss',
3253
	'example_request_data' => array(
3254
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
3255
		'body' => array(
3256
			'css' => '.stie-title { color: #fff; }',
3257
			'preprocessor' => 'sass'
3258
		),
3259
	),
3260
	'example_response' => '
3261
	{
3262
		"css": ".site-title { color: #fff; }",
3263
		"preprocessor": "sass",
3264
		"add_to_existing": "true"
3265
	}'
3266
) );
3267
3268
/**
3269
 * Site Logo endpoint
3270
 */
3271
new WPCOM_JSON_API_Update_Site_Logo_Endpoint( array (
3272
	'description'      => 'Set site logo settings',
3273
	'group'            => '__do_not_document',
3274
	'stat'             => 'sites:1:logo',
3275
	'method'           => 'POST',
3276
	'min_version'      => '1.1',
3277
	'path'             => '/sites/%s/logo',
3278
	'path_labels'      => array(
3279
		'$site' => '(string) Site ID or domain.',
3280
	),
3281
	'request_format'  => array(
3282
		'id' => '(int) The ID of the logo post',
3283
		'url' => '(string) The URL of the logo post',
3284
	),
3285
	'response_format'  => array(
3286
		'id' => '(int) The ID of the logo post',
3287
		'url' => '(string) The URL of the logo post',
3288
	),
3289
	'example_request'  => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/logo',
3290
	'example_request_data' => array(
3291
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
3292
		'body' => array(
3293
			'id' => 12345,
3294
			'url' => 'https://s.w.org/about/images/logos/codeispoetry-rgb.png',
3295
		),
3296
	),
3297
	'example_response' => '
3298
	{
3299
		"id": 12345,
3300
		"url": "https:\/\/s.w.org\/about\/images\/logos\/codeispoetry-rgb.png"
3301
	}'
3302
) );
3303
3304
new WPCOM_JSON_API_Update_Site_Logo_Endpoint( array (
3305
	'description'      => 'Delete site logo settings',
3306
	'group'            => '__do_not_document',
3307
	'stat'             => 'sites:1:logo:delete',
3308
	'method'           => 'POST',
3309
	'min_version'      => '1.1',
3310
	'path'             => '/sites/%s/logo/delete',
3311
	'path_labels'      => array(
3312
		'$site' => '(string) Site ID or domain.',
3313
	),
3314
	'example_request'  => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/logo/delete',
3315
	'example_request_data' => array(
3316
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
3317
	),
3318
) );
3319
3320
/**
3321
 * Site Homepage endpoint
3322
 */
3323
new WPCOM_JSON_API_Update_Site_Homepage_Endpoint( array (
3324
	'description'      => 'Set site homepage settings',
3325
	'group'            => '__do_not_document',
3326
	'stat'             => 'sites:1:homepage',
3327
	'method'           => 'POST',
3328
	'min_version'      => '1.1',
3329
	'path'             => '/sites/%s/homepage',
3330
	'path_labels'      => array(
3331
		'$site' => '(string) Site ID or domain.',
3332
	),
3333
	'request_format'  => array(
3334
		'is_page_on_front' => '(bool) True if we will use a page as the homepage; false to use a blog page as the homepage.',
3335
		'page_on_front_id' => '(int) Optional. The ID of the page to use as the homepage if is_page_on_front is true.',
3336
		'page_for_posts_id' => '(int) Optional. The ID of the page to use as the blog page if is_page_on_front is true.',
3337
	),
3338
	'response_format'  => array(
3339
		'is_page_on_front' => '(bool) True if we will use a page as the homepage; false to use a blog page as the homepage.',
3340
		'page_on_front_id' => '(int) The ID of the page to use as the homepage if is_page_on_front is true.',
3341
		'page_for_posts_id' => '(int) The ID of the page to use as the blog page if is_page_on_front is true.',
3342
	),
3343
	'example_request'  => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/homepage',
3344
	'example_request_data' => array(
3345
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
3346
		'body' => array(
3347
			'is_page_on_front' => true,
3348
			'page_on_front_id' => 1,
3349
			'page_for_posts_id' => 0,
3350
		),
3351
	),
3352
	'example_response' => '{"is_page_on_front":true,"page_on_front_id":1,"page_for_posts_id":0}'
3353
) );
3354
3355
/*
3356
 * Custom Menus endpoints
3357
 */
3358
new WPCOM_JSON_API_Menus_New_Menu_Endpoint( array (
3359
	'method' => 'POST',
3360
	'description' => 'Create a new navigation menu.',
3361
	'group' => 'menus',
3362
	'stat' => 'menus:new-menu',
3363
	'path' => '/sites/%s/menus/new',
3364
	'path_labels' => array(
3365
		'$site' => '(int|string) Site ID or domain',
3366
	),
3367
	'request_format'  => array(
3368
		'name' => '(string) Name of menu',
3369
	),
3370
	'response_format' => array(
3371
		'id' => '(int) Newly created menu ID',
3372
	),
3373
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/menus/new',
3374
	'example_request_data' => array(
3375
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
3376
		'body' => array(
3377
			'name' => 'Menu 1'
3378
		)
3379
	),
3380
) );
3381
3382
new WPCOM_JSON_API_Menus_Update_Menu_Endpoint( array (
3383
	'method' => 'POST',
3384
	'description' => 'Update a navigation menu.',
3385
	'group' => 'menus',
3386
	'stat' => 'menus:update-menu',
3387
	'path' => '/sites/%s/menus/%d',
3388
	'path_labels' => array(
3389
		'$site' => '(int|string) Site ID or domain',
3390
		'$menu_id' => '(int) Menu ID',
3391
	),
3392
	'request_format'  => array(
3393
		'name'  => '(string) Name of menu',
3394
		'items' => '(array) A list of menu item objects.
3395
			<br/><br/>
3396
			Item objects contain fields relating to that item, e.g. id, type, content_id,
3397
			but they can also contain other items objects - this nesting represents parents
3398
			and child items in the item tree.'
3399
	),
3400
	'response_format' => array(
3401
		'menu' => '(object) Updated menu object',
3402
	),
3403
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/menus/510604099',
3404
	'example_request_data' => array(
3405
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
3406
		'body' => array(
3407
			'name' => 'Test Menu'
3408
		),
3409
	),
3410
) );
3411
3412
new WPCOM_JSON_API_Menus_List_Menus_Endpoint( array (
3413
	'method'=> 'GET',
3414
	'description' => 'Get a list of all navigation menus.',
3415
	'group' => 'menus',
3416
	'stat' => 'menus:list-menu',
3417
	'path' => '/sites/%s/menus',
3418
	'path_labels' => array(
3419
		'$site' => '(int|string) Site ID or domain',
3420
	),
3421
	'response_format' => array(
3422
		'menus' => '(array) A list of menu objects.<br/><br/>
3423
			A menu object contains a name, items, locations, etc.
3424
			Check the example response for the full structure.
3425
			<br/><br/>
3426
			Item objects contain fields relating to that item, e.g. id, type, content_id,
3427
			but they can also contain other items objects - this nesting represents parents
3428
			and child items in the item tree.',
3429
		'locations' => '(array) Locations where menus can be placed. List of objects, one per location.'
3430
	),
3431
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/menus',
3432
	'example_request_data' => array(
3433
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
3434
	),
3435
) );
3436
3437
new WPCOM_JSON_API_Menus_Get_Menu_Endpoint( array (
3438
	'method'=> 'GET',
3439
	'description' => 'Get a single navigation menu.',
3440
	'group' => 'menus',
3441
	'stat' => 'menus:get-menu',
3442
	'path' => '/sites/%s/menus/%d',
3443
	'path_labels' => array(
3444
		'$site' => '(int|string) Site ID or domain',
3445
		'$menu_id' => '(int) Menu ID',
3446
	),
3447
	'response_format' => array(
3448
		'menu' => '(object) A menu object.<br/><br/>
3449
			A menu object contains a name, items, locations, etc.
3450
			Check the example response for the full structure.
3451
			<br/><br/>
3452
			Item objects contain fields relating to that item, e.g. id, type, content_id,
3453
			but they can also contain other items objects - this nesting represents parents
3454
			and child items in the item tree.'
3455
	),
3456
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/menus/510604099',
3457
	'example_request_data' => array(
3458
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
3459
	),
3460
) );
3461
3462
new WPCOM_JSON_API_Menus_Delete_Menu_Endpoint( array (
3463
	'method' => 'POST',
3464
	'description' => 'Delete a navigation menu',
3465
	'group' => 'menus',
3466
	'stat' => 'menus:delete-menu',
3467
	'path' => '/sites/%s/menus/%d/delete',
3468
	'path_labels' => array(
3469
		'$site' => '(int|string) Site ID or domain',
3470
		'$menu_id' => '(int) Menu ID',
3471
	),
3472
	'response_format' => array(
3473
		'deleted' => '(bool) Has the menu been deleted?',
3474
	),
3475
	'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/menus/$menu_id/delete',
3476
	'example_request_data' => array(
3477
		'headers' => array( 'authorization' => 'Bearer YOUR_API_TOKEN' ),
3478
	),
3479
) );
3480
3481
new WPCOM_JSON_API_Publicize_Endpoint( array(
3482
	'description' => 'Share a post.',
3483
	'group'       => '__do_not_document',
3484
	'stat'        => 'publicize:new',
3485
	'min_version' => '1',
3486
	'method'      => 'POST',
3487
	'force'       => 'wpcom',
3488
	'path'        => '/sites/%s/post/%d/publicize',
3489
	'path_labels' => array(
3490
		'$site' => '(int|string) Site ID or domain',
3491
		'$post_id' => '(int) Post ID',
3492
	),
3493
3494
	'request_format'  => array(
3495
		'message'  => '(string) The custom message that gets publicized',
3496
		'skipped_connections' => '(array) List of publicize account ids that we don\'t want publicize to',
3497
		'connections' => '(array) List of publicize account ids that we want to publicize to',
3498
		'share_date' => '(int) Time for the message to publish',
3499
	),
3500
3501
	'response_format' => array(
3502
		'success' => '(bool) Whether the operation was successful',
3503
	),
3504
3505
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/post/1/publicize/',
3506
	'example_request_data' => array(
3507
		'headers' => array(
3508
			'authorization' => 'Bearer YOUR_API_TOKEN'
3509
		),
3510
		'body' => array(
3511
			'message'   => 'Hello World',
3512
			'share_date'		=> '1490045140',
3513
		)
3514
	)
3515
 ) );
3516
3517
new WPCOM_JSON_API_List_Publicize_Scheduled_Actions_Endpoint( array(
3518
	'description' => 'List scheduled  publicize actions for a post.',
3519
	'group'       => '__do_not_document',
3520
	'stat'        => 'publicize:list_scheduled',
3521
	'min_version' => '1',
3522
	'method'      => 'GET',
3523
	'force'       => 'wpcom',
3524
	'path'        => '/sites/%s/post/%d/publicize/scheduled',
3525
	'path_labels' => array(
3526
		'$site' => '(int|string) Site ID or domain',
3527
		'$post_id' => '(int) Post ID',
3528
	),
3529
3530
	'response_format' => array(
3531
		'items' => '(array) Actions',
3532
	),
3533
3534
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/post/1/publicize/scheduled',
3535
	'example_request_data' => array(
3536
		'headers' => array(
3537
			'authorization' => 'Bearer YOUR_API_TOKEN'
3538
		)
3539
	)
3540
 ) );
3541
3542
new WPCOM_JSON_API_List_Publicize_Published_Actions_Endpoint( array(
3543
	'description' => 'List scheduled and published publicize actions for a post.',
3544
	'group'       => '__do_not_document',
3545
	'stat'        => 'publicize:list_published',
3546
	'min_version' => '1',
3547
	'method'      => 'GET',
3548
	'force'       => 'wpcom',
3549
	'path'        => '/sites/%s/post/%d/publicize/published',
3550
	'path_labels' => array(
3551
		'$site' => '(int|string) Site ID or domain',
3552
		'$post_id' => '(int) Post ID',
3553
	),
3554
3555
	'response_format' => array(
3556
		'items' => '(array) Actions',
3557
	),
3558
3559
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/post/1/publicize/published',
3560
	'example_request_data' => array(
3561
		'headers' => array(
3562
			'authorization' => 'Bearer YOUR_API_TOKEN'
3563
		)
3564
	)
3565
 ) );
3566
3567
new WPCOM_JSON_API_Edit_Publicize_Scheduled_Action_Endpoint( array(
3568
	'description' => 'Edit scheduled publicize action for a post.',
3569
	'group'       => '__do_not_document',
3570
	'stat'        => 'publicize:edit_action',
3571
	'min_version' => '1',
3572
	'method'      => 'POST',
3573
	'force'       => 'wpcom',
3574
	'path'        => '/sites/%s/post/%d/publicize/action/%s/edit',
3575
	'path_labels' => array(
3576
		'$site' => '(int|string) Site ID or domain',
3577
		'$post_id' => '(int) Post ID',
3578
		'$id' => '(string) Publicize action ID',
3579
	),
3580
	'request_format'  => array(
3581
		'message'  => '(string) The custom message that gets publicized',
3582
		'share_date' => '(int) Time for the message to publish',
3583
	),
3584
	'response_format' => array(
3585
		'id' => '(string) ID of new publicize action',
3586
	),
3587
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/post/1/publicize/action/15505463_1489962162_58cf04b27b662/edit/',
3588
	'example_request_data' => array(
3589
		'headers' => array(
3590
			'authorization' => 'Bearer YOUR_API_TOKEN'
3591
		),
3592
		'body' => array(
3593
			'message'   => 'Hello World',
3594
			'share_date'		=> '1490045140',
3595
		)
3596
	)
3597
 ) );
3598
new WPCOM_JSON_API_Delete_Publicize_Scheduled_Action_Endpoint( array(
3599
	'description' => 'Delete scheduled publicize action for a post.',
3600
	'group'       => '__do_not_document',
3601
	'stat'        => 'publicize:delete_action',
3602
	'min_version' => '1',
3603
	'method'      => 'POST',
3604
	'force'       => 'wpcom',
3605
	'path'        => '/sites/%s/post/%d/publicize/action/%s/delete',
3606
	'path_labels' => array(
3607
		'$site' => '(int|string) Site ID or domain',
3608
		'$post_id' => '(int) Post ID',
3609
		'$id' => '(string) Publicize action ID',
3610
	),
3611
3612
	'response_format' => array(
3613
		'success' => '(bool) Action was succesfully deleted?',
3614
	),
3615
3616
	'example_request'      => 'https://public-api.wordpress.com/rest/v1/sites/82974409/post/1/publicize/action/15505463_1489962162_58cf04b27b662/delete/',
3617
	'example_request_data' => array(
3618
		'headers' => array(
3619
			'authorization' => 'Bearer YOUR_API_TOKEN'
3620
		)
3621
	)
3622
 ) );
3623