Skip to content
This repository has been archived by the owner on Sep 24, 2018. It is now read-only.

Commit

Permalink
Merge pull request #321 from WP-API/cookie-docs-fix
Browse files Browse the repository at this point in the history
json_register_scripts - wpApiOptions.nonce is now WP_API_Settings.nonce
  • Loading branch information
rmccue committed Jun 30, 2014
2 parents 7721c9a + 18c05f2 commit 1598c86
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ POST data or in the query for GET requests), or via the `X-WP-Nonce` header.
As an example, this is how the built-in Javascript client creates the nonce:

```php
wp_localize_script( 'wp-api', 'wpApiOptions', array( 'base' => json_url(), 'nonce' => wp_create_nonce( 'wp_json' ) ) );
wp_localize_script( 'wp-api', 'WP_API_Settings', array( 'root' => esc_url_raw( get_json_url() ), 'nonce' => wp_create_nonce( 'wp_json' ) ) );
```

This is then used in the base model:

```javascript
options.beforeSend = function(xhr) {
xhr.setRequestHeader('X-WP-Nonce', wpApiOptions.nonce);
xhr.setRequestHeader('X-WP-Nonce', WP_API_Settings.nonce);

if (beforeSend) {
return beforeSend.apply(this, arguments);
Expand Down

0 comments on commit 1598c86

Please sign in to comment.