Created
June 4, 2025 15:37
-
-
Save svandragt/e8e9826e2b97d9d0d2316fa3dcaab94b to your computer and use it in GitHub Desktop.
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 | |
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