Allow user override of GOOGLE_ANALYTICATOR_CLIENTID and friends
-
Hi guys,
We’re a huge site using your plugin and we’re going to start using the authentication built into the plugin to run queries on our Analytics to generate “popular posts” headlines. As such we’ll be making a lot more queries than usual through the authentication API.
When we turned this on tentatively the result was that our site started showing authentication errors due to too many requests. I had seen that before in the dashboard but only occasionally, probably the result of a perfect storm of all your users logging into their dashboards. This was a different situation though, the error showed all across the site and didn’t go away; I think our traffic was enough to put your token over the edge permanently (FWIW we probably broke everyone’s dashboards for awhile due to this issue, SORRY!)
So what we need to do is use our own GOOGLE_ANALYTICATOR_CLIENTID and GOOGLE_ANALYTICATOR_CLIENTSECRET that we set up with Google Apps. This will keep us safe from your limits and keep all the other users of your plugin safe from ours.
Two obvious solutions jump to mind. The most direct would be to just check if they are already defined before declaring them, so that users could declare them in wp-config.php or an /mu-plugins/ to override:
if (!defined('GOOGLE_ANALYTICATOR_CLIENTID')) define('GOOGLE_ANALYTICATOR_CLIENTID', '1007949979410.apps.googleusercontent.com'); if (!defined('GOOGLE_ANALYTICATOR_CLIENTSECRET')) define('GOOGLE_ANALYTICATOR_CLIENTSECRET', 'q06U41XDXtzaXD14E-KO1hti'); //don't worry - this don't
Alternatively you could run a filter on your value before declaring it. That would give devs a lot more options as to how to change the value, but to do that you’d have to move the declarations into a hooked callback on ‘init’ to allow the filters to be registered in other plugins/functions.php.
Since I assume you’d rather less changes than more the !defined() solution is probably the one you’d like. Either would be fine in my books as long as I get a way to use my own API keys ??
Thanks for taking the time to review this, hopefully we can fix this so the power users of your plugin can stop causing errors for everyone else (I’m sure we’re not the only ones who would prefer to use our own keys).
- The topic ‘Allow user override of GOOGLE_ANALYTICATOR_CLIENTID and friends’ is closed to new replies.