This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = new XMLHttpRequest(); | |
request.open('GET', 'http://www.mywordpressurl.com/wp-json/test/v1/posts/', true); | |
request.onload = function() { | |
// se la richiesta ha successo | |
if (request.status >= 200 && request.status < 400) { | |
var data = JSON.parse(request.responseText); | |
console.log(data); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ecco l'action che fa funzionare la nostra chiamata | |
add_action('rest_api_init', function () { | |
// registriamo la nuova rotta, il primo parametro equivale al namespace, potrebbe essere myplugin/v1 ecc ecc | |
// il secondo parametro equivale al percorso che vogliamo usare e le eventuali opzioni, | |
// in questo esempio abbiamo aggiunto il parametro id, questo valore sarà poi disponibile nella funzione di callback | |
register_rest_route( 'test/v1', '/post/(?P<id>\d+)', array( | |
'methods' => 'GET', // specifichiamo il metodo http | |
// specifichiamo la funzione di callback dove andremo a specificare cosa ritornare |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once __DIR__ . '/sentry-php/lib/Raven/Autoloader.php'; | |
Raven_Autoloader::register(); | |
$client = new Raven_Client('https://***:***@sentry.io/***'); | |
$error_handler = new Raven_ErrorHandler($client); |