woothemes/woocommerce — pull request #3026 by MZAWeb (2013-04-25 01:35:51+00:00)
Title: Make easier for 3rd party plugins to get reports and charts info

Current situation:

If you need to link to a specific chart from outside the reports page, pretty much your only* option is to hardcode the full link, including the chart ID. But the ID now is just the array index, and it will change every time you add a chart, or a plugin or theme decides to change the order of the charts. What's worst, from 1.6 to 2.0.8 it changed 2 times, so it's really hard to maintain a 3rd part plugin that requires such link.

* There's an insane option too:
1) Hook into woocommerce_reports_charts
2) Open an output buffer and call woocommerce_reports(), and then discard the output buffer.
3) Loop through the array and use the chart name or callback function to get the array index. Take into account that the name could be localized and the callback function could have been changed by another plugin.

What this small patch does:
1) Extract the reports and charts definition to a new woocommerce_get_reports_charts() function so third party plugins can get easily the data.

2) Add a string key to each chart so it's easier and more reliable to identify them, because order, name and function can change, with some degree of certainty that the key won't change in the future.