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

wpApiSettings is printed twice #162

Closed
ocean90 opened this issue Feb 14, 2017 · 1 comment
Closed

wpApiSettings is printed twice #162

ocean90 opened this issue Feb 14, 2017 · 1 comment

Comments

@ocean90
Copy link
Contributor

ocean90 commented Feb 14, 2017

When using the plugin with 4.7 the wpApiSettings variable gets printed twice:

<script type='text/javascript'>
/* <![CDATA[ */
var wpApiSettings = {"root":"http:\/\/example.local\/wp-json\/","nonce":"4c587e2a05","versionString":"wp\/v2\/"};
var wpApiSettings = {"root":"http:\/\/example.local\/wp-json\/","nonce":"4c587e2a05","versionString":"wp\/v2\/","schema":{"namespace":"wp\/v2","routes":{"\/wp\/v2":{"namespace":"wp\/v2","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"namespace":{"required":false,"default":"wp\/v2"},

A fix would be to reset the existing data like so:

if ( isset( $scripts->registered['wp-api'] ) && isset( $scripts->registered['wp-api']->extra['data'] ) ) {
	$scripts->registered['wp-api']->extra['data'] = '';
}

We could also try to merge the data but I don't think it's necessary here.

@adamsilverstein
Copy link

Development of the client is continuing in core. We should avoid loading the plugin for wp >= 4.7. Closing in favor of #169.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants