Skip to content

Commit 0e22b81

Browse files
committed
Update README for 4.7, re-point links to reference developer.w.org
Fixes #293 The documentation in the README (and therefore the node-wpapi.wp-api.org site) is out-of-date: it points to the legacy wp-api.org instead of the new developer.wordpress.org/rest-api handbook, and it references plugin-era methods instead of the new, standardized core methods for cookie authentication. Props @bkirby989 for reporting this discrepancy.
1 parent 5a9dc75 commit 0e22b81

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
104104

105105
### Auto-Discovery
106106

107-
It is also possible to leverage the [capability discovery](http://v2.wp-api.org/guide/discovery/) features of the API to automatically detect and add setter methods for your custom routes, or routes added by plugins.
107+
It is also possible to leverage the [capability discovery](https://developer.wordpress.org/rest-api/using-the-rest-api/discovery/) features of the API to automatically detect and add setter methods for your custom routes, or routes added by plugins.
108108

109109
To utilize the auto-discovery functionality, call `WPAPI.discover()` with a URL within a WordPress REST API-enabled site:
110110

@@ -200,7 +200,7 @@ wp.posts().create({
200200
})
201201
```
202202

203-
This will work in the same manner for resources other than `post`: you can see the list of required data parameters for each resource on the [WP REST API Documentation Website](http://v2.wp-api.org/reference/).
203+
This will work in the same manner for resources other than `post`: you can see the list of required data parameters for each resource on the [WP REST API Documentation Website](https://developer.wordpress.org/rest-api/reference/).
204204

205205
### Updating Posts
206206

@@ -225,7 +225,7 @@ wp.posts().id( 2501 ).update({
225225
})
226226
```
227227

228-
This will work in the same manner for resources other than `post`: you can see the list of required data parameters for each resource on the [WP REST API Documentation Website](http://v2.wp-api.org/reference/).
228+
This will work in the same manner for resources other than `post`: you can see the list of required data parameters for each resource on the [WP REST API Documentation Website](https://developer.wordpress.org/rest-api/reference/).
229229

230230
### Requesting Different Resources
231231

@@ -461,7 +461,7 @@ wp.posts.id( idOfProtectedPost )
461461

462462
#### Other Filters
463463

464-
The `?filter` query parameter is not natively supported within the WordPress core REST API endpoints, but can be added to your site using a plugin. `filter` is a special query parameter that lets you directly specify many WP_Query arguments, including `tag`, `author_name`, and other [public query vars](https://codex.wordpress.org/WordPress_Query_Vars). Even more parameters are available for use with `filter` if you [authenticate with the API](http://v2.wp-api.org/guide/authentication/).
464+
The `?filter` query parameter is not natively supported within the WordPress core REST API endpoints, but can be added to your site using the [rest-filter plugin](https://github.com/wp-api/rest-filter). `filter` is a special query parameter that lets you directly specify many WP_Query arguments, including `tag`, `author_name`, and other [public query vars](https://codex.wordpress.org/WordPress_Query_Vars). Even more parameters are available for use with `filter` once you [authenticate with the API](https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/).
465465

466466
If your environment supports this parameter, other filtering methods will be available if you initialize your site [using auto-discovery](http://wp-api.org/node-wpapi/using-the-client/#auto-discovery), which will auto-detect the availability of `filter`:
467467

@@ -664,18 +664,18 @@ This will include an `._embedded` object in the response JSON, which contains al
664664
"_embedded": {
665665
"author": [ /* ... */ ],
666666
"replies": [ /* ... */ ],
667-
"http://v2.wp-api.org/attachment": [ /* ... */ ],
668-
"http://v2.wp-api.org/term": [
667+
"wp:attachment": [ /* ... */ ],
668+
"wp:term": [
669669
[ {}, {} /* category terms */ ],
670670
[ {} /* tag terms */ ],
671671
/* etc... */
672672
],
673-
"http://v2.wp-api.org/meta": [ /* ... */ ]
673+
"wp:meta": [ /* ... */ ]
674674
}
675675
}
676676
```
677677

678-
For more on working with embedded data, [check out the WP-API documentation](http://v2.wp-api.org/).
678+
For more on working with embedded data, [check out the WP-API documentation](https://developer.wordpress.org/rest-api/using-the-rest-api/linking-and-embedding/).
679679

680680
## Collection Pagination
681681

@@ -851,17 +851,17 @@ More robust authentication methods will hopefully be added; we would welcome con
851851
852852
### Cookie Authentication
853853
854-
When the library is loaded from the frontend of the WordPress site you are querying against, you can utilize the build in [Cookie authentication](http://wp-api.org/guides/authentication.html) supported by WP REST API.
854+
When the library is loaded from the frontend of the WordPress site you are querying against, you can utilize the build in [Cookie authentication](https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/#cookie-authentication) supported by WP REST API.
855855
856856
First localize your scripts with an object with root-url and nonce in your theme's `functions.php` or your plugin:
857857
858858
```php
859859
function my_enqueue_scripts() {
860860
wp_enqueue_script( 'app', get_template_directory_uri() . '/assets/dist/bundle.js', array(), false, true );
861861
wp_localize_script( 'app', 'WP_API_Settings', array(
862-
'endpoint' => esc_url_raw( get_json_url() ),
863-
'nonce' => wp_create_nonce( 'wp_json' ) )
864-
);
862+
'root' => esc_url_raw( rest_url() ),
863+
'nonce' => wp_create_nonce( 'wp_rest' )
864+
) );
865865
}
866866
add_action( 'wp_enqueue_scripts', 'my_enqueue_scripts' );
867867
```

0 commit comments

Comments
 (0)