Skip to content

Instantly share code, notes, and snippets.

@svandragt
Created June 4, 2025 15:37
Show Gist options
  • Save svandragt/e8e9826e2b97d9d0d2316fa3dcaab94b to your computer and use it in GitHub Desktop.
Save svandragt/e8e9826e2b97d9d0d2316fa3dcaab94b to your computer and use it in GitHub Desktop.
<?php
const REST_NAMESPACE = 'test/v1';
add_action( 'rest_api_init', function () {
register_rest_route( REST_NAMESPACE, '/test', [
'methods' => 'GET',
'callback' => 'handle_rest_test',
'permission_callback' => '__return_true',
] );
} );
/**
* Handle REST API test endpoint request.
*
* @return \WP_REST_Response
*/
function handle_rest_test() : \WP_REST_Response {
return new \WP_REST_Response( [
'message' => 'Hello from REST API',
] );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment