Home Blog Add Australia’s Current Population To Your Website

Add Australia’s Current Population To Your Website

0

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:

24,947,152

This projection is based on the estimated resident population at and assumes growth since then of:

  • One birth every 1 minute and 43 seconds.
  • One death every 3 minutes and 16 seconds.
  • A net gain of one international migration every 2 minutes and 18 seconds.
  • An overall total population increase of one person every 1 minute and 24 seconds.
  • These assumptions are consistent with figures released in Australian Demographic Statistics, September Quarter 2017 (cat. no. 3101.0)

    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

    Using 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.

    24,947,152

    style

    The style is applied to the population figure only. By default we use font-size: 2.0em; color: #008000; text-align: center; text-decoration: bold;.

    cache

    We cache data for 18 hours by default only because we have no need to provide accurate numbers. Alter as required.

    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

    • The ABS JSON data unfolds as follows. Used 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.

    Download

    Title: Add Australia's Current Population To Your Website
    Description: Add Australia's Current Population To Your Website. Sourced from ABS.
    Download: Shortcode (V0.1) | PHP Code (V0.1) | Plugin Page

    Shortt URL for this post: http://shor.tt/2nYw

LEAVE A REPLY

Please enter your comment!
Please enter your name here