One of the key specifications for this plugin is the ability to set how often content is refreshed. Maybe you want to include a "quote of the day" on your site, or maybe you want to update a chunk of content every hour. Each instance of our widget needs an expiration date.
How do we do that? The solution is a bit tricky, so pay attention. First, we need to add another control option to our widget that allows the managers to set how often the content expires in each widget instance. We are referring to this as the "shelf life", in keeping with some common grocery terms.
Update the ContentRotatorWidget.php
file so the $control_options
array has an additional option:
public $control_options = array( 'title' => 'Content Rotator', 'seconds_shelf_life' => 86400, // 86400 seconds in a day );
We have given it a default value of 86400; we are opting to use seconds as our refresh interval, where 86,400 seconds is equal to 24...