Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created February 4, 2012 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchristopher/1739100 to your computer and use it in GitHub Desktop.
Save jchristopher/1739100 to your computer and use it in GitHub Desktop.
The form() for our Image of the Month Widget
<?php
function form( $instance )
{
$headline = esc_attr( isset( $instance['headline'] ) ? $instance['headline'] : '' );
$image_id = esc_attr( isset( $instance[$this->image_field] ) ? $instance[$this->image_field] : 0 );
$blurb = esc_attr( isset( $instance['blurb'] ) ? $instance['blurb'] : '' );
$image = new WidgetImageField( $this, $image_id );
?>
<p>
<label for="<?php echo $this->get_field_id( 'headline' ); ?>"><?php _e( 'Headline:' ); ?>
<input class="widefat" id="<?php echo $this->get_field_id( 'headline' ); ?>" name="<?php echo $this->get_field_name( 'headline' ); ?>" type="text" value="<?php echo $headline; ?>" />
</label>
</p>
<div>
<label><?php _e( 'Image:' ); ?></label>
<?php echo $image->get_widget_field(); ?>
</div>
<p>
<label for="<?php echo $this->get_field_id( 'blurb' ); ?>"><?php _e( 'Blurb:' ); ?>
<input class="widefat" id="<?php echo $this->get_field_id( 'blurb' ); ?>" name="<?php echo $this->get_field_name( 'blurb' ); ?>" type="text" value="<?php echo $blurb; ?>" />
</label>
</p>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment