Interface for saving Open Data endpoints as WordPress Transients.
This WordPress Plugin will provide an interface in the WP Admin to save saving external Open Data as WordPress transients and a developer API to interact with them. You can read more about the WordPress Transients API in the Codex.
- Admin Interface (Settings > Open Data Transients) for adding new transients and adding an Open Data token.
- Transients can be updated manually in the Admin, but they are set to expire weekly (using the WordPress constant
- Developer API for getting the transient data, and updating it automatically if it is expired.
composer/installers to install it to the plugin directly using Composer. Just run:
composer require nyco/wp-open-data-transients
You can also download the package and add it manually to your plugin directory.
A token will be sent in the header (
X-App-Token) to the Open Data endpoint to authenticate your application for for saving data. This can be set in the same admin or as an environment variable
$_ENV['OPEN_DATA_APP_TOKEN']. The NYCO WP Config plugin can be used to manage environment variables.
Transients can be saved by adding a valid name (letters and underscores only) and valid url. Clicking "Save Transient" will save the transient and cache the request. Once it is saved, the developer API can be used to get the data. The developer API also exposes the save and set methods used by the admin interface.
Typing the name of an already saved transient and clicking "Save Transient" will update the transient data cache.
Once the plugin is installed, you can reference the name space to use it;
use nyco\WpOpenDataTransients\Transients\Transients as Transients;
set_transient methods to retrieve the saved endpoint and save the response body. It will expect a JSON response and will be saved as a PHP Object.
Returns a saved transient. If the transient is empty (expired) it will use the
set method to re-cache it.
This plugin only provides a small interface for saving external Open Data as WordPress Transients and external data and is not a fully fledged transient manager.
- Method to delete saved transients.
- Option to set the expiration of transients.
NYC Opportunity is the New York City Mayor's Office for Economic Opportunity. We are committed to sharing open source software that we use in our products. Feel free to ask questions and share feedback. Follow @nycopportunity on Github, Twitter, Facebook, and Instagram.