What exactly do we want this plugin to do? Our widget will display a random bit of text from the database. This type of plugin is frequently used for advertisement rotations or in situations where you want to spruce up a page by rotating content on a periodic basis. Each instance of our plugin will also have a "shelf life" that will determine how frequently its content should be randomized.
Let's take a moment to come up with some specifications for this plugin. We want it to do the following:
Store multiple chunks of content, such as bits of Google Adsense code
Be able to randomly return one of the chunks
Set a time limit that defines the "shelf life" of each chunk, after which the "random" chunk will be updated
As with our other chapters, there are existing plugins you can download that do this already, but our focus here is showing you how to write the code.