Make WordPress Core

Changeset 38832

Timestamp:
10/20/2016 02:54:12 AM (8 years ago)
Author:
rachelbaker
Message:

REST API: Introduce the Content API endpoints.

REST API endpoints for your WordPress content. These endpoints provide machine-readable external access to your WordPress site with a clear, standards-driven interface, allowing new and innovative apps for interacting with your site. These endpoints support all of the following:

  • Posts: Read and write access to all post data, for all types of post-based data, including pages and media.
  • Comments: Read and write access to all comment data. This includes pingbacks and trackbacks.
  • Terms: Read and write access to all term data.
  • Users: Read and write access to all user data. This includes public access to some data for post authors.
  • Meta: Read and write access to metadata for posts, comments, terms, and users, on an opt-in basis from plugins.
  • Settings: Read and write access to settings, on an opt-in basis from plugins and core. This enables API management of key site content values that are technically stored in options, such as site title and byline.

Love your REST API, WordPress! The infrastructure says, "Let's do lunch!" but the content API endpoints say, "You're paying!"

Props rmccue, rachelbaker, danielbachhuber, joehoyle, adamsilverstein, afurculita, ahmadawais, airesvsg, alisspers, antisilent, apokalyptik, artoliukkonen, attitude, boonebgorges, bradyvercher, brianhogg, caseypatrickdriscoll, chopinbach, chredd, christianesperar, chrisvanpatten, claudiolabarbera, claudiosmweb, cmmarslender, codebykat, coderkevin, codfish, codonnell822, daggerhart, danielpunkass, davidbhayes, delphinus, desrosj, dimadin, dotancohen, DrewAPicture, Dudo1985, duncanjbrown, eherman24, eivhyl, eliorivero, elyobo, en-alis, ericandrewlewis, ericpedia, evansobkowicz, fjarrett, frozzare, georgestephanis, greatislander, guavaworks, hideokamoto, hkdobrev, hubdotcom, hurtige, iandunn, ircrash, ironpaperweight, iseulde, Japh, jaredcobb, JDGrimes, jdolan, jdoubleu, jeremyfelt, jimt, jjeaton, jmusal, jnylen0, johanmynhardt, johnbillion, jonathanbardo, jorbin, joshkadis, JPry, jshreve, jtsternberg, JustinSainton, kacperszurek, kadamwhite, kalenjohnson, kellbot, kjbenk, kokarn, krogsgard, kuchenundkakao, kuldipem, kwight, lgedeon, lukepettway, mantismamita, markoheijnen, matrixik, mattheu, mauteri, maxcutler, mayukojpn, michael-arestad, miyauchi, mjbanks, modemlooper, mrbobbybryant, NateWr, nathanrice, netweb, NikV, nullvariable, oskosk, oso96_2000, oxymoron, pcfreak30, pento, peterwilsoncc, Pezzab, phh, pippinsplugins, pjgalbraith, pkevan, pollyplummer, pushred, quasel, QWp6t, schlessera, schrapel, Shelob9, shprink, simonlampen, Soean, solal, tapsboy, tfrommen, tharsheblows, thenbrent, tierra, tlovett1, tnegri, tobych, Toddses, toro_unit, traversal, vanillalounge, vishalkakadiya, wanecek, web2style, webbgaraget, websupporter, westonruter, whyisjake, wonderboymusic, wpsmith, xknown, zyphonic.
Fixes #38373.

Location:
trunk
Files:
38 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-filters.php

    r38829 r38832  
    375375// REST API actions.
    376376add_action( 'init',          'rest_api_init' );
    377 add_action( 'rest_api_init', 'rest_api_default_filters', 10, 1 );
     377add_action( 'rest_api_init', 'rest_api_default_filters',   10, 1 );
     378add_action( 'rest_api_init', 'register_initial_settings',  10 );
     379add_action( 'rest_api_init', 'create_initial_rest_routes', 99 );
    378380add_action( 'parse_request', 'rest_api_loaded' );
    379381
  • trunk/src/wp-includes/functions.php

    r38814 r38832  
    34313431
    34323432/**
     3433
     3434
     3435
     3436
     3437
     3438
     3439
     3440
     3441
     3442
     3443
     3444
     3445
     3446
     3447
     3448
     3449
     3450
     3451
     3452
    34333453 * Extract a slice of an array, given a list of keys.
    34343454 *
  • trunk/src/wp-includes/option.php

    r38818 r38832  
    17091709
    17101710/**
     1711
     1712
     1713
     1714
     1715
     1716
     1717
     1718
     1719
     1720
     1721
     1722
     1723
     1724
     1725
     1726
     1727
     1728
     1729
     1730
     1731
     1732
     1733
     1734
     1735
     1736
     1737
     1738
     1739
     1740
     1741
     1742
     1743
     1744
     1745
     1746
     1747
     1748
     1749
     1750
     1751
     1752
     1753
     1754
     1755
     1756
     1757
     1758
     1759
     1760
     1761
     1762
     1763
     1764
     1765
     1766
     1767
     1768
     1769
     1770
     1771
     1772
     1773
     1774
     1775
     1776
     1777
     1778
     1779
     1780
     1781
     1782
     1783
     1784
     1785
     1786
     1787
     1788
     1789
     1790
     1791
     1792
     1793
     1794
     1795
     1796
     1797
     1798
     1799
     1800
     1801
     1802
     1803
     1804
     1805
     1806
     1807
     1808
     1809
     1810
     1811
     1812
     1813
     1814
     1815
     1816
     1817
     1818
     1819
    17111820 * Register a setting and its data.
    17121821 *
  • trunk/src/wp-includes/post.php

    r38829 r38832  
    3434        'delete_with_user' => true,
    3535        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),
     36
     37
     38
    3639    ) );
    3740
     
    5255        'delete_with_user' => true,
    5356        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions' ),
     57
     58
     59
    5460    ) );
    5561
     
    7783        'delete_with_user' => true,
    7884        'supports' => array( 'title', 'author', 'comments' ),
     85
     86
     87
    7988    ) );
    8089    add_post_type_support( 'attachment:audio', 'thumbnail' );
  • trunk/src/wp-includes/rest-api.php

    r38806 r38832  
    7272
    7373/**
     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
    74116 * Registers rewrite rules for the API.
    75117 *
     
    123165
    124166    add_filter( 'rest_pre_dispatch', 'rest_handle_options_request', 10, 3 );
     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
    125232}
    126233
     
    684791    return array( $local, $utc );
    685792}
     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
     1001
     1002
     1003
     1004
     1005
     1006
     1007
     1008
     1009
     1010
     1011
     1012
     1013
     1014
     1015
     1016
     1017
     1018
     1019
     1020
     1021
     1022
     1023
     1024
     1025
     1026
     1027
     1028
     1029
     1030
     1031
     1032
     1033
     1034
     1035
     1036
     1037
     1038
     1039
     1040
     1041
     1042
     1043
     1044
     1045
     1046
     1047
     1048
     1049
     1050
     1051
     1052
     1053
     1054
     1055
     1056
     1057
     1058
     1059
     1060
     1061
     1062
     1063
     1064
     1065
     1066
     1067
     1068
     1069
     1070
     1071
     1072
     1073
     1074
     1075
     1076
     1077
     1078
     1079
     1080
     1081
     1082
     1083
     1084
     1085
  • trunk/src/wp-includes/script-loader.php

    r38827 r38832  
    499499    $scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 );
    500500    $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'jquery', 'media-views', 'media-audiovideo' ), false, 1 );
     501
     502
     503
     504
     505
     506
     507
    501508
    502509    if ( is_admin() ) {
  • trunk/src/wp-includes/taxonomy.php

    r38779 r38832  
    6868            'assign_terms' => 'assign_categories',
    6969        ),
     70
     71
     72
    7073    ) );
    7174
     
    8487            'assign_terms' => 'assign_post_tags',
    8588        ),
     89
     90
     91
    8692    ) );
    8793
  • trunk/src/wp-settings.php

    r38747 r38832  
    219219require( ABSPATH . WPINC . '/rest-api/class-wp-rest-response.php' );
    220220require( ABSPATH . WPINC . '/rest-api/class-wp-rest-request.php' );
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
     232
     233
     234
     235
     236
    221237
    222238$GLOBALS['wp_embed'] = new WP_Embed();
  • trunk/tests/phpunit/includes/bootstrap.php

    r38454 r38832  
    4040define( 'WP_MEMORY_LIMIT', -1 );
    4141define( 'WP_MAX_MEMORY_LIMIT', -1 );
     42
     43
    4244
    4345$PHP_SELF = $GLOBALS['PHP_SELF'] = $_SERVER['PHP_SELF'] = '/index.php';
     
    8991require dirname( __FILE__ ) . '/testcase.php';
    9092require dirname( __FILE__ ) . '/testcase-rest-api.php';
     93
     94
    9195require dirname( __FILE__ ) . '/testcase-xmlrpc.php';
    9296require dirname( __FILE__ ) . '/testcase-ajax.php';
  • trunk/tests/phpunit/includes/utils.php

    r36525 r38832  
    454454    return $i;
    455455}
     456
     457
     458
     459
     460
     461
     462
     463
     464
     465
     466
     467
     468
     469
     470
     471
     472
     473
     474
  • trunk/tests/phpunit/tests/rest-api.php

    r38790 r38832  
    2727        $this->assertTrue( class_exists( 'WP_REST_Request' ) );
    2828        $this->assertTrue( class_exists( 'WP_REST_Response' ) );
     29
    2930    }
    3031
     
    3536    function test_init_action_added() {
    3637        $this->assertEquals( 10, has_action( 'init', 'rest_api_init' ) );
     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
    3767    }
    3868
Note: See TracChangeset for help on using the changeset viewer.