You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reorder global parameters page (put _embed earlier)
This page is currently unordered, so this PR restructures it to put the most-used/useful properties first.
My sense of what is useful is informed primarily by how frequently I have heard each one referenced since the merge of the API.
The API natively supports [JSONP](https://en.wikipedia.org/wiki/JSONP) responses to allow cross-domain requests for legacy browsers and clients. This parameter takes a JavaScript callback function which will be prepended to the data. This URL can then be loaded via a `<script>` tag.
42
39
43
-
The callback function can contain any alphanumeric, `_` (underscore), or `.` (period) character. Callbacks which contain invalid characters will receive a HTTP 400 error response, and the callback will not be called.
40
+
## `_embed`
44
41
45
-
[info]
46
-
Modern browsers can use <ahref="https://en.wikipedia.org/wiki/Cross-origin_resource_sharing">Cross-Origin Resource Sharing (CORS)</a> preflight requests for cross-domain requests, but JSONP can be used to ensure support with all browsers.
42
+
Most resources include links to related resources. For example, a post can link to the parent post, or to comments on the post. To reduce the number of HTTP requests required, clients may wish to fetch a resource as well as the linked resources. The `_embed` parameter indicates to the server that the response should include these embedded resources.
<li><ahref="https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS">MDN Article on CORS</a></li>
51
-
</ul>
52
-
[/info]
44
+
Embed mode is enabled if the `_embed` parameter is passed in the query string (GET parameter). This parameter does not require a value (i.e. `?_embed` is valid), however can be passed "1" as a value if required by a client library.
53
45
54
-
For example:
46
+
[info]For future compatibility, other values should not be passed.[/info]
55
47
56
-
```html
57
-
<script>
58
-
functionreceiveData( data ) {
59
-
// Do something with the data here.
60
-
// For demonstration purposes, we'll simply log it.
Resources in embed mode will contain an additional `_embedded` key next to the `_links` key containing the linked resources. Only links with the `embeddable` parameter set to `true` will be embedded.
66
49
50
+
For more about linking and embedding, see the [Linking and Embedding](https://developer.wordpress.org/rest-api/linking-and-embedding/) page.
67
51
68
52
## `_method` (or `X-HTTP-Method-Override` header)
69
53
@@ -85,7 +69,6 @@ Host: example.com
85
69
X-HTTP-Method-Override: DELETE
86
70
```
87
71
88
-
89
72
## `_envelope`
90
73
91
74
Similarly to `_method`, some servers, clients, and proxies do not support accessing the full response data. The API supports passing an `_envelope` parameter, which sends all response data in the body, including headers and status code.
@@ -126,17 +109,30 @@ HTTP/1.1 200 OK
126
109
}
127
110
```
128
111
112
+
## `_jsonp`
129
113
130
-
## `_embed`
131
-
132
-
Most resources include links to related resources. For example, a post can link to the parent post, or to comments on the post. To reduce the number of HTTP requests required, clients may wish to fetch a resource as well as the linked resources. The `_embed` parameter indicates to the server that the response should include these embedded resources.
114
+
The API natively supports [JSONP](https://en.wikipedia.org/wiki/JSONP) responses to allow cross-domain requests for legacy browsers and clients. This parameter takes a JavaScript callback function which will be prepended to the data. This URL can then be loaded via a `<script>` tag.
133
115
134
-
Embed mode is enabled if the `_embed` parameter is passed in the query string (GET parameter). This parameter does not require a value (i.e. `?_embed` is valid), however can be passed "1" as a value if required by a client library.
116
+
The callback function can contain any alphanumeric, `_` (underscore), or `.` (period) character. Callbacks which contain invalid characters will receive a HTTP 400 error response, and the callback will not be called.
135
117
136
118
[info]
137
-
For future compatibility, other values should not be passed.
119
+
Modern browsers can use <ahref="https://en.wikipedia.org/wiki/Cross-origin_resource_sharing">Cross-Origin Resource Sharing (CORS)</a> preflight requests for cross-domain requests, but JSONP can be used to ensure support with all browsers.
<li><ahref="https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS">MDN Article on CORS</a></li>
124
+
</ul>
138
125
[/info]
139
126
140
-
Resources in embed mode will contain an additional `_embedded` key next to the `_links` key containing the linked resources. Only links with the `embeddable` parameter set to `true` will be embedded.
127
+
For example:
141
128
142
-
For more about linking and embedding, see the [Linking and Embedding](https://developer.wordpress.org/rest-api/linking-and-embedding/) page.
129
+
```html
130
+
<script>
131
+
functionreceiveData( data ) {
132
+
// Do something with the data here.
133
+
// For demonstration purposes, we'll simply log it.
0 commit comments