REST API endpoint to retrieve current server datetime with remote IP and GPS coordinates of request.
- PHP 5.6+ (tested up to 8.2)
- WordPress 5.7+
- Download the WordPress installable ZIP archive camaleaun-localize.1.0.0.zip.
- Log in to your WordPress dashboard.
- Navigate to "Plugins" > "Add New."
- Click on the "Upload Plugin" button.
- Choose the
camaleaun-localize.1.0.0.zip
file you downloaded. - Click on the "Install Now" button.
- Once the installation is complete, click on the "Activate" button to activate the plugin.
The usage is based in WordPress REST API.
Query endpoint to retrieve localize data.
GET
/camaleaun/v1/localize
There are no arguments for this endpoint.
Atribute | Type | Description |
---|---|---|
datetime |
datetime | The current server datetime in the site's timezone. |
remote_ip |
string | Remote IP from request. |
location |
string | GPS coordinates (Latitude/Longitude) from the remote_ip . |
The default response format is JSON.
Successful requests will return a 200 OK
HTTP status.
- Datetime is returned in ISO 8601 format:
YYYY-MM-DDTHH:MM:SS+00:00
, e.g. 2023-01-24T11:18:46+01:00. - GPS coordinates (Latitude/Longitude) is returned in Decimal Degrees (DD) format, e.g. 49.202442, 16.615052.
Note: The examples provided in this README assume that permalinks are enabled in your WordPress installation. If you are using non-pretty permalinks, you can pass the REST API route as a query string parameter:
http://example.com/?rest_route=/camaleaun/v1/localize
. Please make sure to adjust the examples according to your permalink settings.
$ curl https://example.com/wp-json/camaleaun/v1/localize
{
"current_time": "2023-01-24T11:18:46+01:00",
"remote_ip": "69.241.108.45",
"location": "49.202442, 16.615052"
}
- Trellis: https://roots.io/docs/trellis/master/installation/
- Bedrock: https://roots.io/docs/bedrock/master/installation/
- Sage: https://roots.io/docs/sage/9.x/installation/
- WordPress REST API: https://developer.wordpress.org/rest-api/