PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 5.1.4
Jetpack – WP Security, Backup, Speed, & Growth v5.1.4
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / json-endpoints.php

json-endpoints.php in Jetpack – WP Security, Backup, Speed, & Growth 5.1.4, at json-endpoints.php

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