PHP code example of underpin / rest-endpoint-loader
1. Go to this page and download the library: Download underpin/rest-endpoint-loader library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
underpin / rest-endpoint-loader example snippets
// Register rest endpoint
underpin()->rest_endpoints()->add( 'example-endpoint', [
'endpoint_callback' => function ( \WP_REST_Request $request ) {
return [ 'result' => 'Wow this worked nicely!' ];
},
'has_permission_callback' => '__return_true',
'rest_namespace' => 'example/v1',
'route' => 'example-endpoint',
'args' => [ 'methods' => 'GET' ],
] );
underpin()->rest_endpoints()->add('endpoint-key','Namespace\To\Class');