I want to keep track of how long a specific WordPress theme has been active, not just installed. The end goal being I want to display a notice after a user has created x
number of posts and the theme has been active for y
hours.
I can handle displaying a notice, and counting the number of posts published in a specific time, but I was wondering if there is a good way to keep track of how many hours the theme has been active.
I imagine the best way would be to set an option or something stored in the database, and update this each hour? Or maybe save a timestamp in the database of when the theme was activated and when the theme was deactivated (initially 0
or null
), then check these two variables and the current timestamp to determine how long its been active?
Thank you for any help you can offer!