Contractor Stopwatch
A stopwatch gizmo for WordPress
by John Dee · github.com/johndeebdd/stopwatch-block · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/johndeebdd/stopwatch-block/archive/refs/heads/master.zipReadme
This is a WordPress plugin that displays a frontend "stopwatch".
Usage
To activate the plugin, enter the WordPress shortcode [contractor-stopwatch] in the content of your post.

API: Save Data
This endpoint collects the data for the stop watch.
URL : /wp-json/contractor-stopwatch/v1/save-data
Method : POST
Auth required : pending - ignore for now
Data
| argument name | type | description | required |
|---|---|---|---|
| postID | integer | the WordPress post ID | yes [or data will not be saved] |
| startStopArray | array | the stopwatch sessions | no |
Data Example
2 compleated stopwatch sessions
Even number of entries = clock is NOT running
[
1575676690324,
1575676691682,
1575676692360,
1575676693925
]
1 compleate session + start time
Odd number of entries = clock IS running
[
1575676690324,
1575676691682,
1575676692360
]
Clock has not started yet / reset state
[]
Javascript Hidden Variable
postID is a hidden variable available on the frontend, sent from the server. It is the WordPress post ID on the server. It must be sent back to the server when sending data.
RESPONSES
Success
Code : 200 OK
Content
Success!
Error
Condition : typo or some other error
Code : 404 BAD REQUEST
Content :
{
code: "rest_no_route",
message: "No route was found matching the URL and request method",
data: {
status: 404
}
}
API: Get Data
This endpoint sends the data to the stop watch.
URL : /wp-json/contractor-stopwatch/v1/get-data
Method : POST
Auth required : pending - ignore for now
Data
| argument name | type | description | required |
|---|---|---|---|
| postID | integer | the WordPress post ID | yes |
Data Example
This endpoint returns the exact data submitted in /save-data
