INN / Google-Analytics-Popular-Posts

A WordPress plugin that uses Google Analytics data to determine the most popular posts on your site and display a list of popular posts via the included widget.
https://wordpress.org/plugins/ga-popular-posts/
23 stars 7 forks source link

Change cron to longer timeframe? #77

Closed newvision2112 closed 6 years ago

newvision2112 commented 6 years ago

Hello,

Plugin works great, but do not need the cron to run every 20 minutes to get new analytics data and then run the queries for most popular posts. For our site, it would be enough to run every 12 or 24 hours.

Is there a place in the code to change this from 20 minutes to once every 12 or 24 hours?

Thanks, Dean

benlk commented 6 years ago

The code would seem to run it every 10 minutes: https://github.com/INN/Google-Analytics-Popular-Posts/blob/07e235585149e0ee24d4b9be6a6e3516ee58f64a/inc/analytic-bridge-installing.php#L93

The '10m' in that isn't a time, but instead a string label for the time interval described here, adding some new cron schedules: https://github.com/INN/Google-Analytics-Popular-Posts/blob/d3a5ffccec1902fe158e7f69ba4f708f49e15fdd/analytic-bridge.php#L51-L62

You could fork this plugin to modify that interval to one of the WordPress-provided defaults: https://developer.wordpress.org/plugins/cron/understanding-wp-cron-scheduling/

aschweigert commented 6 years ago

making that first value filterable might be a better way to go if this is a thing folks would commonly want to modify on a site by site basis

newvision2112 commented 6 years ago

Hi Ben, Thank you for clarifying. The documentation mentions it runs once every 20 minutes. I'll dig into the code and see what I can modify via the cron info you shared.

Best, Dean