This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
json-endpoints.php
2515 lines (2289 loc) · 109 KB
/
json-endpoints.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
* Endpoint class definitions. Only instantiations should be in this file
* file ordering matters
*/
$json_endpoints_dir = dirname( __FILE__ ) . '/json-endpoints/';
//abstract endpoints
require_once( $json_endpoints_dir . 'class.wpcom-json-api-post-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-post-v1-1-endpoint.php' ); // v1.1
require_once( $json_endpoints_dir . 'class.wpcom-json-api-comment-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-taxonomy-endpoint.php' );
// **********
// v1
// **********
require_once( $json_endpoints_dir . 'class.wpcom-json-api-delete-media-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-comment-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-media-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-post-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-render-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-render-shortcode-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-shortcodes-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-render-embed-reversal-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-render-embed-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-embeds-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-site-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-taxonomies-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-taxonomy-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-comments-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-media-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-posts-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-users-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-comment-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-media-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-post-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-taxonomy-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-upload-media-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-site-settings-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-publicize-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-sharing-buttons-endpoint.php' );
// **********
// v1.1
// **********
// Media
require_once( $json_endpoints_dir . 'class.wpcom-json-api-delete-media-v1-1-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-media-v1-1-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-media-v1-1-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-media-v1-1-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-upload-media-v1-1-endpoint.php' );
// Posts
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-post-v1-1-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-list-posts-v1-1-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-post-v1-1-endpoint.php' );
require_once( $json_endpoints_dir . 'class.wpcom-json-api-get-post-counts-v1-1-endpoint.php' );
// Custom Menus
require_once( $json_endpoints_dir . 'class.wpcom-json-api-menus-v1-1-endpoint.php' );
// **********
// v1.2
// **********
require_once( $json_endpoints_dir . 'class.wpcom-json-api-update-post-v1-2-endpoint.php' );
// Jetpack Only Endpoints
$json_jetpack_endpoints_dir = dirname( __FILE__ ) . '/json-endpoints/jetpack/';
// This files instantiates the endpoints
require_once( $json_jetpack_endpoints_dir . 'json-api-jetpack-endpoints.php' );
/*
* Endpoint instantiations
*/
new WPCOM_JSON_API_GET_Site_Endpoint( array(
'description' => 'Get information about a site.',
'group' => 'sites',
'stat' => 'sites:X',
'allowed_if_flagged' => true,
'method' => 'GET',
'path' => '/sites/%s',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
),
'query_parameters' => array(
'context' => false,
),
'response_format' => WPCOM_JSON_API_GET_Site_Endpoint::$site_format,
'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/',
) );
new WPCOM_JSON_API_GET_Post_Counts_V1_1_Endpoint( array(
'description' => 'Get number of posts in the post type groups by post status',
'group' => '__do_not_document',
'stat' => 'sites:X:post-counts:X',
'force' => 'wpcom',
'method' => 'GET',
'min_version' => '1.1',
'max_version' => '1.2',
'path' => '/sites/%s/post-counts/%s',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
'$post_type' => '(string) Post Type',
),
'query_parameters' => array(
'context' => false,
),
'example_request' => 'https://public-api.wordpress.com/rest/v1.2/sites/en.blog.wordpress.com/post-counts/page',
'response_format' => array(
'statuses' => '(array) Number of posts in the post type grouped by post status',
)
) );
new WPCOM_JSON_API_List_Post_Formats_Endpoint( array(
'description' => 'Get a list of post formats supported by a site.',
'group' => '__do_not_document',
'stat' => 'sites:X:post-formats',
'method' => 'GET',
'path' => '/sites/%s/post-formats',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
),
'query_parameters' => array(
'context' => false,
),
'response_format' => array(
'formats' => '(array) A list of supported post formats. id => label.',
)
) );
new WPCOM_JSON_API_List_Page_Templates_Endpoint( array(
'description' => 'Get a list of page templates supported by a site.',
'group' => '__do_not_document',
'stat' => 'sites:X:post-templates',
'method' => 'GET',
'path' => '/sites/%s/page-templates',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
),
'query_parameters' => array(
'context' => false,
),
'response_format' => array(
'templates' => '(array) A list of supported page templates. Contains label and file.',
)
) );
new WPCOM_JSON_API_List_Post_Types_Endpoint( array (
'description' => 'Get a list of post types available for a site.',
'group' => '__do_not_document',
'stat' => 'sites:X:post-types',
'method' => 'GET',
'path' => '/sites/%s/post-types',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
),
'query_parameters' => array(
'api_queryable' => '(bool) If true, only queryable post types are returned',
),
'response_format' => array(
'found' => '(int) The number of post types found',
'post_types' => '(array) A list of available post types',
)
) );
/*
* Shortcode endpoints
*/
new WPCOM_JSON_API_List_Shortcodes_Endpoint( array(
'description' => "Get a list of shortcodes available on a site. Note: The current user must have publishing access.",
'group' => 'sites',
'stat' => 'shortcodes',
'method' => 'GET',
'path' => '/sites/%s/shortcodes',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
),
'response_format' => array(
'shortcodes' => '(array) A list of supported shortcodes by their handle.',
),
'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/shortcodes',
'example_request_data' => array(
'headers' => array(
'authorization' => 'Bearer YOUR_API_TOKEN'
),
)
) );
new WPCOM_JSON_API_Render_Shortcode_Endpoint( array(
'description' => "Get a rendered shortcode for a site. Note: The current user must have publishing access.",
'group' => 'sites',
'stat' => 'shortcodes:render',
'method' => 'GET',
'path' => '/sites/%s/shortcodes/render',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
),
'query_parameters' => array(
'shortcode' => '(string) The query-string encoded shortcode string to render. Required. Only accepts one at a time.',
),
'response_format' => array(
'shortcode' => '(string) The shortcode that was passed in for rendering.',
'result' => '(html) The rendered HTML result of the shortcode.',
'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.',
'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.',
),
'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/shortcodes/render?shortcode=%5Bgallery%20ids%3D%22729%2C732%2C731%2C720%22%5D',
'example_request_data' => array(
'headers' => array(
'authorization' => 'Bearer YOUR_API_TOKEN'
),
)
) );
/*
* embed endpoints
*/
new WPCOM_JSON_API_List_Embeds_Endpoint( array(
'description' => "Get a list of embeds available on a site. Note: The current user must have publishing access.",
'group' => 'sites',
'stat' => 'embeds',
'method' => 'GET',
'path' => '/sites/%s/embeds',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
),
'response_format' => array(
'embeds' => '(array) A list of supported embeds by their regex pattern.',
),
'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/embeds',
'example_request_data' => array(
'headers' => array(
'authorization' => 'Bearer YOUR_API_TOKEN'
),
)
) );
new WPCOM_JSON_API_Render_Embed_Endpoint( array(
'description' => "Get a rendered embed for a site. Note: The current user must have publishing access.",
'group' => 'sites',
'stat' => 'embeds:render',
'method' => 'GET',
'path' => '/sites/%s/embeds/render',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
),
'query_parameters' => array(
'embed_url' => '(string) The query-string encoded embed URL to render. Required. Only accepts one at a time.',
),
'response_format' => array(
'embed_url' => '(string) The embed_url that was passed in for rendering.',
'result' => '(html) The rendered HTML result of the embed.',
),
'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',
'example_request_data' => array(
'headers' => array(
'authorization' => 'Bearer YOUR_API_TOKEN'
),
)
) );
new WPCOM_JSON_API_Render_Embed_Reversal_Endpoint( array(
'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.",
//'group' => 'sites',
'group' => '__do_not_document',
'stat' => 'embeds:reversal',
'method' => 'POST',
'path' => '/sites/%s/embeds/reversal',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
),
'request_format' => array(
'maybe_embed' => '(string) The embed code to reverse. Required. Only accepts one at a time.',
),
'response_format' => array(
'maybe_embed' => '(string) The original embed code that was passed in for rendering.',
'reversal_type' => '(string) The type of reversal. Either an embed or a shortcode.',
'render_result' => '(html) The rendered HTML result of the embed or shortcode.',
'result' => '(string) The reversed content. Either a single line embed or a shortcode.',
'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.',
'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.',
),
'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/shortcode-reversals/render/',
'example_request_data' => array(
'headers' => array(
'authorization' => 'Bearer YOUR_API_TOKEN'
),
'body' => array(
'maybe_embed' => '<iframe width="480" height="302" src="http://www.ustream.tv/embed/recorded/26370522/highlight/299667?v=3&wmode=direct" scrolling="no" frameborder="0"></iframe>',
)
),
) );
/*
* Post endpoints
*/
new WPCOM_JSON_API_List_Posts_Endpoint( array(
'description' => 'Get a list of matching posts.',
'new_version' => '1.1',
'max_version' => '1',
'group' => 'posts',
'stat' => 'posts',
'method' => 'GET',
'path' => '/sites/%s/posts/',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
),
'query_parameters' => array(
'number' => '(int=20) The number of posts to return. Limit: 100.',
'offset' => '(int=0) 0-indexed offset.',
'page' => '(int) Return the Nth 1-indexed page of posts. Takes precedence over the <code>offset</code> parameter.',
'order' => array(
'DESC' => 'Return posts in descending order. For dates, that means newest to oldest.',
'ASC' => 'Return posts in ascending order. For dates, that means oldest to newest.',
),
'order_by' => array(
'date' => 'Order by the created time of each post.',
'modified' => 'Order by the modified time of each post.',
'title' => "Order lexicographically by the posts' titles.",
'comment_count' => 'Order by the number of comments for each post.',
'ID' => 'Order by post ID.',
),
'after' => '(ISO 8601 datetime) Return posts dated on or after the specified datetime.',
'before' => '(ISO 8601 datetime) Return posts dated on or before the specified datetime.',
'tag' => '(string) Specify the tag name or slug.',
'category' => '(string) Specify the category name or slug.',
'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.",
'parent_id' => '(int) Returns only posts which are children of the specified post. Applies only to hierarchical post types.',
'exclude' => '(array:int|int) Excludes the specified post ID(s) from the response',
'exclude_tree' => '(int) Excludes the specified post and all of its descendants from the response. Applies only to hierarchical post types.',
'status' => array(
'publish' => 'Return only published posts.',
'private' => 'Return only private posts.',
'draft' => 'Return only draft posts.',
'pending' => 'Return only posts pending editorial approval.',
'future' => 'Return only posts scheduled for future publishing.',
'trash' => 'Return only posts in the trash.',
'any' => 'Return all posts regardless of status.',
),
'sticky' => array(
'false' => 'Post is not marked as sticky.',
'true' => 'Stick the post to the front page.',
),
'author' => "(int) Author's user ID",
'search' => '(string) Search query',
'meta_key' => '(string) Metadata key that the post should contain',
'meta_value' => '(string) Metadata value that the post should contain. Will only be applied if a `meta_key` is also given',
),
'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/posts/?number=5'
) );
new WPCOM_JSON_API_List_Posts_v1_1_Endpoint( array(
'description' => 'Get a list of matching posts.',
'min_version' => '1.1',
'max_version' => '1.1',
'group' => 'posts',
'stat' => 'posts',
'method' => 'GET',
'path' => '/sites/%s/posts/',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
),
'query_parameters' => array(
'number' => '(int=20) The number of posts to return. Limit: 100.',
'offset' => '(int=0) 0-indexed offset.',
'page' => '(int) Return the Nth 1-indexed page of posts. Takes precedence over the <code>offset</code> parameter.',
'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.',
'order' => array(
'DESC' => 'Return posts in descending order. For dates, that means newest to oldest.',
'ASC' => 'Return posts in ascending order. For dates, that means oldest to newest.',
),
'order_by' => array(
'date' => 'Order by the created time of each post.',
'modified' => 'Order by the modified time of each post.',
'title' => "Order lexicographically by the posts' titles.",
'comment_count' => 'Order by the number of comments for each post.',
'ID' => 'Order by post ID.',
),
'after' => '(ISO 8601 datetime) Return posts dated after the specified datetime.',
'before' => '(ISO 8601 datetime) Return posts dated before the specified datetime.',
'modified_after' => '(ISO 8601 datetime) Return posts modified after the specified datetime.',
'modified_before' => '(ISO 8601 datetime) Return posts modified before the specified datetime.',
'tag' => '(string) Specify the tag name or slug.',
'category' => '(string) Specify the category name or slug.',
'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.",
'parent_id' => '(int) Returns only posts which are children of the specified post. Applies only to hierarchical post types.',
'exclude' => '(array:int|int) Excludes the specified post ID(s) from the response',
'exclude_tree' => '(int) Excludes the specified post and all of its descendants from the response. Applies only to hierarchical post types.',
'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"',
'sticky' => array(
'include' => 'Sticky posts are not excluded from the list.',
'exclude' => 'Sticky posts are excluded from the list.',
'require' => 'Only include sticky posts',
),
'author' => "(int) Author's user ID",
'search' => '(string) Search query',
'meta_key' => '(string) Metadata key that the post should contain',
'meta_value' => '(string) Metadata value that the post should contain. Will only be applied if a `meta_key` is also given',
),
'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/en.blog.wordpress.com/posts/?number=2'
) );
new WPCOM_JSON_API_Get_Post_Endpoint( array(
'description' => 'Get a single post (by ID).',
'group' => 'posts',
'stat' => 'posts:1',
'new_version' => '1.1',
'max_version' => '1',
'method' => 'GET',
'path' => '/sites/%s/posts/%d',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
'$post_ID' => '(int) The post ID',
),
'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/posts/7'
) );
new WPCOM_JSON_API_Get_Post_v1_1_Endpoint( array(
'description' => 'Get a single post (by ID).',
'min_version' => '1.1',
'max_version' => '1.1',
'group' => 'posts',
'stat' => 'posts:1',
'method' => 'GET',
'path' => '/sites/%s/posts/%d',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
'$post_ID' => '(int) The post ID',
),
'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/en.blog.wordpress.com/posts/7'
) );
new WPCOM_JSON_API_Get_Post_Endpoint( array(
'description' => 'Get a single post (by name)',
'group' => '__do_not_document',
'stat' => 'posts:name',
'method' => 'GET',
'path' => '/sites/%s/posts/name:%s',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
'$post_name' => '(string) The post name (a.k.a. slug)',
),
'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/posts/name:blogging-and-stuff?pretty=1',
) );
new WPCOM_JSON_API_Get_Post_Endpoint( array(
'description' => 'Get a single post (by slug).',
'group' => 'posts',
'stat' => 'posts:slug',
'new_version' => '1.1',
'max_version' => '1',
'method' => 'GET',
'path' => '/sites/%s/posts/slug:%s',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
'$post_slug' => '(string) The post slug (a.k.a. sanitized name)',
),
'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/posts/slug:blogging-and-stuff',
) );
new WPCOM_JSON_API_Get_Post_v1_1_Endpoint( array(
'description' => 'Get a single post (by slug).',
'min_version' => '1.1',
'max_version' => '1.1',
'group' => 'posts',
'stat' => 'posts:slug',
'method' => 'GET',
'path' => '/sites/%s/posts/slug:%s',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
'$post_slug' => '(string) The post slug (a.k.a. sanitized name)',
),
'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/en.blog.wordpress.com/posts/slug:blogging-and-stuff',
) );
new WPCOM_JSON_API_Update_Post_Endpoint( array(
'description' => 'Create a post.',
'group' => 'posts',
'stat' => 'posts:new',
'new_version' => '1.1',
'max_version' => '1',
'method' => 'POST',
'path' => '/sites/%s/posts/new',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
),
'request_format' => array(
// explicitly document all input
'date' => "(ISO 8601 datetime) The post's creation time.",
'title' => '(HTML) The post title.',
'content' => '(HTML) The post content.',
'excerpt' => '(HTML) An optional post excerpt.',
'slug' => '(string) The name (slug) for the post, used in URLs.',
'author' => '(string) The username or ID for the user to assign the post to.',
'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.',
'publicize_message' => '(string) Custom message to be publicized to external services.',
'status' => array(
'publish' => 'Publish the post.',
'private' => 'Privately publish the post.',
'draft' => 'Save the post as a draft.',
'pending' => 'Mark the post as pending editorial approval.',
'auto-draft' => 'Save a placeholder for a newly created post, with no content.',
),
'sticky' => array(
'false' => 'Post is not marked as sticky.',
'true' => 'Stick the post to the front page.',
),
'password' => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.',
'parent' => "(int) The post ID of the new post's parent.",
'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.",
'categories' => "(array|string) Comma-separated list or array of categories (name or id)",
'tags' => "(array|string) Comma-separated list or array of tags (name or id)",
'format' => get_post_format_strings(),
'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.",
'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 />" .
"<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>",
'media_urls' => "(array) An array of URLs for images to attach to a post. Sideloads the media in for a post.",
'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.",
'comments_open' => "(bool) Should the post be open to comments? Defaults to the blog's preference.",
'pings_open' => "(bool) Should the post be open to comments? Defaults to the blog's preference.",
'likes_enabled' => "(bool) Should the post be open to likes? Defaults to the blog's preference.",
'sharing_enabled' => "(bool) Should sharing buttons show on this post? Defaults to true.",
'menu_order' => "(int) (Pages Only) the order pages should appear in. Use 0 to maintain alphabetical order.",
),
'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/posts/new/',
'example_request_data' => array(
'headers' => array(
'authorization' => 'Bearer YOUR_API_TOKEN'
),
'body' => array(
'title' => 'Hello World',
'content' => 'Hello. I am a test post. I was created by the API',
'tags' => 'tests',
'categories' => 'API'
)
)
) );
new WPCOM_JSON_API_Update_Post_v1_1_Endpoint( array(
'description' => 'Create a post.',
'group' => 'posts',
'stat' => 'posts:new',
'min_version' => '1.1',
'max_version' => '1.1',
'method' => 'POST',
'path' => '/sites/%s/posts/new',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
),
'request_format' => array(
// explicitly document all input
'date' => "(ISO 8601 datetime) The post's creation time.",
'title' => '(HTML) The post title.',
'content' => '(HTML) The post content.',
'excerpt' => '(HTML) An optional post excerpt.',
'slug' => '(string) The name (slug) for the post, used in URLs.',
'author' => '(string) The username or ID for the user to assign the post to.',
'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.',
'publicize_message' => '(string) Custom message to be publicized to external services.',
'status' => array(
'publish' => 'Publish the post.',
'private' => 'Privately publish the post.',
'draft' => 'Save the post as a draft.',
'pending' => 'Mark the post as pending editorial approval.',
'auto-draft' => 'Save a placeholder for a newly created post, with no content.',
),
'sticky' => array(
'false' => 'Post is not marked as sticky.',
'true' => 'Stick the post to the front page.',
),
'password' => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.',
'parent' => "(int) The post ID of the new post's parent.",
'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.",
'categories' => "(array|string) Comma-separated list or array of categories (name or id)",
'tags' => "(array|string) Comma-separated list or array of tags (name or id)",
'format' => get_post_format_strings(),
'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.",
'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 />" .
"<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>",
'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.",
'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 />" .
"<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>",
'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.",
'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`',
'likes_enabled' => "(bool) Should the post be open to likes? Defaults to the blog's preference.",
'sharing_enabled' => "(bool) Should sharing buttons show on this post? Defaults to true.",
'menu_order' => "(int) (Pages Only) the order pages should appear in. Use 0 to maintain alphabetical order.",
'page_template' => '(string) (Pages Only) The page template this page should use.',
),
'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/new/',
'example_request_data' => array(
'headers' => array(
'authorization' => 'Bearer YOUR_API_TOKEN'
),
'body' => array(
'title' => 'Hello World',
'content' => 'Hello. I am a test post. I was created by the API',
'tags' => 'tests',
'categories' => 'API'
)
)
) );
new WPCOM_JSON_API_Update_Post_v1_2_Endpoint( array(
'description' => 'Create a post.',
'group' => 'posts',
'stat' => 'posts:new',
'min_version' => '1.2',
'max_version' => '1.2',
'method' => 'POST',
'path' => '/sites/%s/posts/new',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
),
'request_format' => array(
// explicitly document all input
'date' => "(ISO 8601 datetime) The post's creation time.",
'title' => '(HTML) The post title.',
'content' => '(HTML) The post content.',
'excerpt' => '(HTML) An optional post excerpt.',
'slug' => '(string) The name (slug) for the post, used in URLs.',
'author' => '(string) The username or ID for the user to assign the post to.',
'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.',
'publicize_message' => '(string) Custom message to be publicized to external services.',
'status' => array(
'publish' => 'Publish the post.',
'private' => 'Privately publish the post.',
'draft' => 'Save the post as a draft.',
'pending' => 'Mark the post as pending editorial approval.',
'auto-draft' => 'Save a placeholder for a newly created post, with no content.',
),
'sticky' => array(
'false' => 'Post is not marked as sticky.',
'true' => 'Stick the post to the front page.',
),
'password' => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.',
'parent' => "(int) The post ID of the new post's parent.",
'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.",
'categories' => "(array|string) Comma-separated list or array of category names",
'tags' => "(array|string) Comma-separated list or array of tag names",
'categories_by_id' => "(array|string) Comma-separated list or array of category IDs",
'tags_by_id' => "(array|string) Comma-separated list or array of tag IDs",
'format' => get_post_format_strings(),
'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.",
'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 />" .
"<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>",
'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.",
'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 />" .
"<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>",
'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.",
'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`',
'likes_enabled' => "(bool) Should the post be open to likes? Defaults to the blog's preference.",
'sharing_enabled' => "(bool) Should sharing buttons show on this post? Defaults to true.",
'menu_order' => "(int) (Pages Only) the order pages should appear in. Use 0 to maintain alphabetical order.",
'page_template' => '(string) (Pages Only) The page template this page should use.',
),
'example_request' => 'https://public-api.wordpress.com/rest/v1.2/sites/82974409/posts/new/',
'example_request_data' => array(
'headers' => array(
'authorization' => 'Bearer YOUR_API_TOKEN'
),
'body' => array(
'title' => 'Hello World',
'content' => 'Hello. I am a test post. I was created by the API',
'tags' => 'tests',
'categories' => 'API'
)
)
) );
new WPCOM_JSON_API_Update_Post_Endpoint( array(
'description' => 'Edit a post.',
'group' => 'posts',
'stat' => 'posts:1:POST',
'new_version' => '1.1',
'max_version' => '1',
'method' => 'POST',
'path' => '/sites/%s/posts/%d',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
'$post_ID' => '(int) The post ID',
),
'request_format' => array(
'date' => "(ISO 8601 datetime) The post's creation time.",
'title' => '(HTML) The post title.',
'content' => '(HTML) The post content.',
'excerpt' => '(HTML) An optional post excerpt.',
'slug' => '(string) The name (slug) for the post, used in URLs.',
'author' => '(string) The username or ID for the user to assign the post to.',
'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.',
'publicize_message' => '(string) Custom message to be publicized to external services.',
'status' => array(
'publish' => 'Publish the post.',
'private' => 'Privately publish the post.',
'draft' => 'Save the post as a draft.',
'pending' => 'Mark the post as pending editorial approval.',
),
'sticky' => array(
'false' => 'Post is not marked as sticky.',
'true' => 'Stick the post to the front page.',
),
'password' => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.',
'parent' => "(int) The post ID of the new post's parent.",
'categories' => "(array|string) Comma-separated list or array of categories (name or id)",
'tags' => "(array|string) Comma-separated list or array of tags (name or id)",
'format' => get_post_format_strings(),
'comments_open' => '(bool) Should the post be open to comments?',
'pings_open' => '(bool) Should the post be open to comments?',
'likes_enabled' => "(bool) Should the post be open to likes?",
'menu_order' => "(int) (Pages Only) the order pages should appear in. Use 0 to maintain alphabetical order.",
'sharing_enabled' => "(bool) Should sharing buttons show on this post?",
'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.",
'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 />" .
"<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>",
'media_urls' => "(array) An array of URLs for images to attach to a post. Sideloads the media in for a post.",
'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.",
),
'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/posts/881',
'example_request_data' => array(
'headers' => array(
'authorization' => 'Bearer YOUR_API_TOKEN'
),
'body' => array(
'title' => 'Hello World (Again)',
'content' => 'Hello. I am an edited post. I was edited by the API',
'tags' => 'tests',
'categories' => 'API'
)
)
) );
new WPCOM_JSON_API_Update_Post_v1_1_Endpoint( array(
'description' => 'Edit a post.',
'group' => 'posts',
'stat' => 'posts:1:POST',
'min_version' => '1.1',
'max_version' => '1.1',
'method' => 'POST',
'path' => '/sites/%s/posts/%d',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
'$post_ID' => '(int) The post ID',
),
'request_format' => array(
'date' => "(ISO 8601 datetime) The post's creation time.",
'title' => '(HTML) The post title.',
'content' => '(HTML) The post content.',
'excerpt' => '(HTML) An optional post excerpt.',
'slug' => '(string) The name (slug) for the post, used in URLs.',
'author' => '(string) The username or ID for the user to assign the post to.',
'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.',
'publicize_message' => '(string) Custom message to be publicized to external services.',
'status' => array(
'publish' => 'Publish the post.',
'private' => 'Privately publish the post.',
'draft' => 'Save the post as a draft.',
'pending' => 'Mark the post as pending editorial approval.',
),
'sticky' => array(
'false' => 'Post is not marked as sticky.',
'true' => 'Stick the post to the front page.',
),
'password' => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.',
'parent' => "(int) The post ID of the new post's parent.",
'categories' => "(array|string) Comma-separated list or array of categories (name or id)",
'tags' => "(array|string) Comma-separated list or array of tags (name or id)",
'format' => get_post_format_strings(),
'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`',
'likes_enabled' => "(bool) Should the post be open to likes?",
'menu_order' => "(int) (Pages only) the order pages should appear in. Use 0 to maintain alphabetical order.",
'page_template' => '(string) (Pages Only) The page template this page should use.',
'sharing_enabled' => "(bool) Should sharing buttons show on this post?",
'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.",
'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 />" .
"<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>",
'media_urls' => "(array) An array of URLs for images to attach to a post. Sideloads the media in for a post.",
'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.",
),
'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/881',
'example_request_data' => array(
'headers' => array(
'authorization' => 'Bearer YOUR_API_TOKEN'
),
'body' => array(
'title' => 'Hello World (Again)',
'content' => 'Hello. I am an edited post. I was edited by the API',
'tags' => 'tests',
'categories' => 'API'
)
)
) );
new WPCOM_JSON_API_Update_Post_v1_2_Endpoint( array(
'description' => 'Edit a post.',
'group' => 'posts',
'stat' => 'posts:1:POST',
'min_version' => '1.2',
'max_version' => '1.2',
'method' => 'POST',
'path' => '/sites/%s/posts/%d',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
'$post_ID' => '(int) The post ID',
),
'request_format' => array(
'date' => "(ISO 8601 datetime) The post's creation time.",
'title' => '(HTML) The post title.',
'content' => '(HTML) The post content.',
'excerpt' => '(HTML) An optional post excerpt.',
'slug' => '(string) The name (slug) for the post, used in URLs.',
'author' => '(string) The username or ID for the user to assign the post to.',
'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.',
'publicize_message' => '(string) Custom message to be publicized to external services.',
'status' => array(
'publish' => 'Publish the post.',
'private' => 'Privately publish the post.',
'draft' => 'Save the post as a draft.',
'pending' => 'Mark the post as pending editorial approval.',
),
'sticky' => array(
'false' => 'Post is not marked as sticky.',
'true' => 'Stick the post to the front page.',
),
'password' => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.',
'parent' => "(int) The post ID of the new post's parent.",
'categories' => "(array|string) Comma-separated list or array of category names",
'categories_by_id' => "(array|string) Comma-separated list or array of category IDs",
'tags' => "(array|string) Comma-separated list or array of tag names",
'tags_by_id' => "(array|string) Comma-separated list or array of tag IDs",
'format' => get_post_format_strings(),
'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`',
'likes_enabled' => "(bool) Should the post be open to likes?",
'menu_order' => "(int) (Pages only) the order pages should appear in. Use 0 to maintain alphabetical order.",
'page_template' => '(string) (Pages Only) The page template this page should use.',
'sharing_enabled' => "(bool) Should sharing buttons show on this post?",
'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.",
'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 />" .
"<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>",
'media_urls' => "(array) An array of URLs for images to attach to a post. Sideloads the media in for a post.",
'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.",
),
'example_request' => 'https://public-api.wordpress.com/rest/v1.2/sites/82974409/posts/881',
'example_request_data' => array(
'headers' => array(
'authorization' => 'Bearer YOUR_API_TOKEN'
),
'body' => array(
'title' => 'Hello World (Again)',
'content' => 'Hello. I am an edited post. I was edited by the API',
'tags' => 'tests',
'categories' => 'API'
)
)
) );
new WPCOM_JSON_API_Update_Post_Endpoint( array(
'description' => 'Delete a post. Note: If the post object is of type post or page and the trash is enabled, this request will send the post to the trash. A second request will permanently delete the post.',
'group' => 'posts',
'stat' => 'posts:1:delete',
'new_version' => '1.1',
'max_version' => '1',
'method' => 'POST',
'path' => '/sites/%s/posts/%d/delete',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
'$post_ID' => '(int) The post ID',
),
'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/posts/$post_ID/delete/',
'example_request_data' => array(
'headers' => array(
'authorization' => 'Bearer YOUR_API_TOKEN'
)
)
) );
new WPCOM_JSON_API_Update_Post_v1_1_Endpoint( array(
'description' => 'Delete a post. Note: If the post object is of type post or page and the trash is enabled, this request will send the post to the trash. A second request will permanently delete the post.',
'group' => 'posts',
'stat' => 'posts:1:delete',
'min_version' => '1.1',
'max_version' => '1.1',
'method' => 'POST',
'path' => '/sites/%s/posts/%d/delete',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
'$post_ID' => '(int) The post ID',
),
'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/$post_ID/delete/',
'example_request_data' => array(
'headers' => array(
'authorization' => 'Bearer YOUR_API_TOKEN'
)
)
) );
new WPCOM_JSON_API_Update_Post_Endpoint( array(
'description' => 'Restore a post or page from the trash to its previous status.',
'group' => 'posts',
'stat' => 'posts:1:restore',
'method' => 'POST',
'new_version' => '1.1',
'max_version' => '1',
'path' => '/sites/%s/posts/%d/restore',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
'$post_ID' => '(int) The post ID',
),
'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/posts/$post_ID/restore/',
'example_request_data' => array(
'headers' => array(
'authorization' => 'Bearer YOUR_API_TOKEN'
)
)
) );
new WPCOM_JSON_API_Update_Post_v1_1_Endpoint( array(
'description' => 'Restore a post or page from the trash to its previous status.',
'group' => 'posts',
'stat' => 'posts:1:restore',
'min_version' => '1.1',
'max_version' => '1.1',
'method' => 'POST',
'path' => '/sites/%s/posts/%d/restore',
'path_labels' => array(
'$site' => '(int|string) Site ID or domain',
'$post_ID' => '(int) The post ID',
),
'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/$post_ID/restore/',
'example_request_data' => array(
'headers' => array(
'authorization' => 'Bearer YOUR_API_TOKEN'
)
)