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

json_register_scripts - wpApiOptions.nonce is now WP_API_Settings.nonce #321

Merged
merged 1 commit into from Jun 30, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/authentication.md
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