While there's a number of organisations that dedicate resources to determining the breakup of PHP's version usage, WordPress maintain their own statistics. Based on their massive coverage, WP's broad reach provides a scientifically and statistically sound source of version data. This article will provide the necessary shortcode to retrieve the WP data and render it into a Google pie chart. The shortcode can also be used to retrieve MySQL and WordPress version usage. See graphs as we've used them on our reference page.
We generally use our own graphing utilities but we'll often revert back to Google charts for more sophisticated renderings.
The Result
The result of the shortcode [phpversions]
is as follows:
At the time of writing, version 5.6 tends to dominate the space with the build representing nearly 40% of all installations.
To generate a donut chart representing WordPress version usage, use a piehole value between 0 and 1 as an attribute (0 is the default, meaning no hole). We'll also specify a name to avoid element ID conflicts and provide a title. For example, [phpversions piehole="0.4" type="wordpress" name="wp_piehole" title="WordPress Version Usage (source: WordPress)"]
. The result:
For the last example we'll render the MySQL chart in 3d. Shortcode of [phpversions name="mysql_threed" type="mysql" 3d="true" title="MySQL Version Usage (source: WordPress)"]
returns:
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. You may optionally download and install our plugin from the bottom of of the page.
Shortcode Attributes
type
type
of chart: php, mysql, or wordpress.name
name
of the chart. This is the div ID so isn't visible in your browser.title
title
. Include WordPress as a source.width
width
.height
height
.piehole
piehole="0.4"
seems to work well. A value of 0 will omit the piehole completely.3d
3d="true"
.cache_temp
cache
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.
PHP Function
A PHP function to be used outside of WordPress is available for download below. Usage requires our Simple Cache. Arguments are passed to the function as an array. Default usage renders a PHP chart.
Considerations
- This shortcode was provided just to demonstrate example usage of live data. Consider it in the marketing realm to measure the success of certain campaigns, clicks against campaign URLs or individuals, sales performance etc.
- When the 3d chart is rendered the piehole feature is unavailable.
- A large number of pie chart features are available. Details here
Download
Title: Using Google Graphs To Draw PHP, MySQL, and WP Version Usage
Description: Displays PHP, MySQL, and WP version usage in a Google Pie Chart. Data sourced from WordPress.
Download • Version 0.1, 2.0K, zip, Category: WordPress Plugins (General)
WordPress Shortcodes, (1.2K) PHP Code & Snippets, (1.3K)