Open pgk opened 7 years ago
This is useful for local REST API development or for embedding the console as a plugin into an existing wordpress installation.
It requires a predefined JavaScript global object is available on the page.
The name of that global is defined in config.json under globalObjectName
example config:
{ "wordpress.org": [ { "name": "localDev", "authType": "local_dev", "globalObjectName": "wpApiSettings", "url": "http://no-need-for-url.com" } ] }
The JS object can be obtained like this (in this case the globalObjectName in the config should be named wpApiSettings)
globalObjectName
wpApiSettings
wp_localize_script( 'wp-api', 'wpApiSettings', array( 'nonce' => wp_create_nonce( 'wp_rest' ), 'url' => esc_url_raw( site_url() ), 'baseUrl' => esc_url_raw( trailingslashit( rest_url() ) ), 'loggedInUserId' => get_current_user_id() ) );
This is useful for local REST API development or for embedding the console as a plugin into an existing wordpress installation.
It requires a predefined JavaScript global object is available on the page.
The name of that global is defined in config.json under globalObjectName
example config:
The JS object can be obtained like this (in this case the
globalObjectName
in the config should be namedwpApiSettings
)