August 2017
Beginner
412 pages
10h 30m
English
The widget form function has to be named form(). You may not rename it if you want the widget class to know what its purpose is. You also need to have an argument in there, which I'm calling $instance, which the class also expects. This is where the current widget settings are stored. This function needs to have all of the functionalities to create the form that users will see when adding the widget to a sidebar. Let's look at some abbreviated code and then explore what it's doing:
public function form($instance) {
$instance = wp_parse_args((array) $instance, array('template' => '')); $current_taxonomy = $this->_get_current_taxonomy($instance); ?> <p> <label for="<?php echo $this->get_field_id('title'); ?>">Title</label> ...Read now
Unlock full access