Adding widget options
The other place where we need to customize our widget's content is in the manager—we need to provide a custom form for editing our widget's options. Let's start by adding a single option for the title. In order to do this, we need to implement another function in our widget and add some options:
- Create a
form()
function that prints out some HTML. Later, this function will print out some HTML form elements, but for now, let's just make sure this works. Add the following function to yourContentRotatorWidget.php
file:/** * Displays the widget form in the manager, used for editing its settings * * @param array $instance The settings for the particular instance of the widget * @return none No value is returned directly, but form ...
Get WordPress 3 Plugin Development Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.