As part of our efforts to provide additional services on our soon-to-be revised Australian Security Journal, we're building a number of APIs that support the information we'd like to generally share and use. One of those APIs deals with Australian Road Fatalities. Since we'd like to provide a reference to the impact of the fatality count over time (say, per 100,000 population), we needed a source of historical population data from which to calculate those numbers. In playing with data from the Australian Bureau of Statistics we stumbled across a funky little tool that provides incremental real-time population growth based on predictive data. The following article will show you how to include that data on your website.
The following shortcode will return data almost exactly as the ABS has done on its website. The shortcode of [bmauspop]
returns the following:
0
This projection is based on the estimated resident population at and assumes growth since then of:
- One birth every .
- One death every .
- A net gain of one international migration every .
- An overall total population increase of one person every .
- The ABS JSON data unfolds as follows. Use as required:
- The data is copyright of the ABS and appropriate attribution should be provided.
- Given the growth rate is provided, you might consider providing projections. Additionally, you might store current data in a cookie or session and then provide growth since a last visit etc.
- There's a lot of data on the ABS website... some that we'll return to over time. In particular, we'll be sourcing finance data for our clients and will incorporate relevant code into the BM Finance Plugin.
These assumptions are consistent with figures released in
We're caching data for 18 hours.
WordPress Shortcode
Copy and paste the WordPress function into your theme's functions.php
file or, if you sensibly have one installed, your custom functions plugin.
Usage requires the Simple Cache plugin. This simply makes life easier by retrieving older data is the transient has expired and the API is unresponsive.
If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.
Shortcode Attributes
The following shortcode attributes are available.
meta
meta="1"
will show the bullet list of data underneath the population (default). To disable, use meta="0"
in your shortcode or hardcode it into the shortcode function. The resulting population figure without meta data is shown below.0
style
font-size: 2.0em; color: #008000; text-align: center; text-decoration: bold;
.cache
PHP Function
Used outside of WordPress, the following may be used. Usage of Simple Cache is required (to avoid making repeated requests to the ABS API).
Considerations
Download
Title: Add Australia's Current Population To Your Website (WP Shortcode)
Description: Add Australia's Current Population To Your Website. Sourced from ABS.
Download • Version 0.1, 989.0B, zip, Category: WordPress Shortcodes
PHP Code & Snippets, (697.0B)