Skip to content

Instantly share code, notes, and snippets.

@dexit
Forked from diogenesjup/exemplo.php
Created February 10, 2025 23:09
Show Gist options
  • Save dexit/553d8bec4ca867680f76aaff728f47c1 to your computer and use it in GitHub Desktop.
Save dexit/553d8bec4ca867680f76aaff728f47c1 to your computer and use it in GitHub Desktop.
<?php
add_action( 'rest_api_init', 'custom_routes_webhook_0277');
function custom_routes_webhook_0277(){
//(exemplo: /wp-json/exemplo/notificacoes)
register_rest_route(
'exemplo', '/notificacoes/', array(
'methods' => 'POST',
'callback' => 'notificacoes_api',
'show_in_index' => false
)
);
}
function notificacoes_api(WP_REST_Request $request){
// Obtendo os dados do POST
$data_received = $request->get_json_params();
// Exemplo acessando dados
// $data_received['id'].... etc
return new WP_REST_Response(array(
'status' => 'sucesso'
), 200);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment