and like us on FB

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:

PHP is said to be used by over 82% of all the websites whose server-side programming language can be identified.

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

The type of chart: php, mysql, or wordpress.

name

The name of the chart. This is the div ID so isn’t visible in your browser.

title

The chart title. Include WordPress as a source.

width

The chart width.

height

The chart height.

piehole

If you want a donut chart use a piehole value higher than 0 and less than 1. A value of piehole="0.4" seems to work well. A value of 0 will omit the piehole completely.

3d

If you want your chart in 3D, use 3d="true".

cache_temp

If the WP API is unavailable, we’ll wait this long before making another request.

cache

The period we’ll cache WP data. Defaults to 14 days.

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 (WordPress API)
Description: Displays PHP, MySQL, and WP version usage in a Google Pie Chart. Data sourced from WordPress.
Download: Shortcode (V0.1) | WP Plugin (V0.1) | PHP Code (V0.1)

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