Object‑oriented WordPress plugin that registers an event custom post type and exposes CRUD operations over the REST API. Only administrators (capability manage_options) can call these endpoints by default.
- POST
/events/create— create an event - POST
/events/update/<event_id>— update an event - GET
/events/list?date=<YYYY-MM-DD>— list events for a date - GET
/events/show?id=<event_id>— fetch a single event - DELETE
/events/delete/<event_id>— delete an event
All endpoints return JSON WP_REST_Response objects with proper HTTP status codes.
- In wp‑admin, open your admin user profile.
- Scroll to “Application Passwords” and click “Add New Application Password”.
- Build the string
<username>:<generated 24‑char password>and Base64 encode it. - Send the header:
Authorization: Basic <base64(username:password)>Example:
Authorization: Basic YWRtaW46WXFtTSBnU2R5IHV2aFIgY0o5RyBaUVRLIHl6ZlY=Create:
curl -X POST \
-H "Authorization: Basic <base64>" \
-H "Content-Type: application/json" \
-d '{"title":"Launch","description":"Kickoff","start_date_time":"2026-01-10","end_date_time":"2026-01-11","category":"Releases"}' \
https://example.com/wp-json/wp-event-api/v1/events/createUpdate:
curl -X POST \
-H "Authorization: Basic <base64>" \
-H "Content-Type: application/json" \
-d '{"title":"Launch v2","description":"Updated","start_date_time":"2026-01-12","end_date_time":"2026-01-13","category":"Releases"}' \
https://example.com/wp-json/wp-event-api/v1/events/update/123The plugin can notify external systems when events change.
Triggers:
created— after a new event is createdupdated— after an event is updateddeleted— after an event is deleted
Each webhook is a non‑blocking POST with JSON body and headers:
Content-Type: application/json
User-Agent: WPEA/<version>
X-WPEA-Event: created|updated|deleted
X-WPEA-Signature: <hmac sha256 of body using secret> # optional if secret is setPayload shape:
{
"action": "created",
"ts": 1733577600,
"site": { "url": "https://example.com/", "name": "Site", "lang": "en_US" },
"plugin": { "slug": "wp-event-api", "version": "1.0.0" },
"payload": {
"event_id": 123,
"title": "Launch",
"start_date_time": "2026-01-10",
"end_date_time": "2026-01-11"
}
}Option (database‑backed):
update_option( 'wpea_webhooks', array(
'created' => array( 'https://example.com/hooks/events-created' ),
'updated' => array( 'https://example.com/hooks/events-updated' ),
'deleted' => array( 'https://example.com/hooks/events-deleted' ),
) );
// Optional signing secret
update_option( 'wpea_webhook_secret', 'your-strong-shared-secret' );Filter (code‑based):
add_filter( 'wpea_webhook_endpoints', function( $endpoints, $action ) {
if ( 'created' === $action ) {
$endpoints[] = 'https://example.com/hooks/created';
}
return $endpoints;
}, 10, 2 );- Post type:
event(supports title, editor; visible in REST) - Taxonomy:
event_cat(hierarchical; visible in REST) - Meta:
start_date_time,end_date_time
- Only users with
manage_optionsmay call the endpoints by default (filterable in code). - Date validation: start must be in the future; end must be greater than start.