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 elements are printed. */ function form( $instance ) { print "Form elements go here"; }
Save your file and refresh your manager page. You should see your handiwork when you open your widget for editing:
You may be thinking that all we need...