Inventory_Presser_Carfax_Widget::form( array $instance )
Outputs the widget settings form that is shown in the dashboard.
On This Page
Parameters Parameters
- $instance
-
(array) (Required)
Return Return
(void)
Source Source
File: includes/widget/class-widget-carfax.php
public function form( $instance ) {
$image_keys = array_keys( $this->images() );
$title = isset( $instance['title'] ) ? $instance['title'] : '';
$before_image = isset( $instance['before_image'] ) ? $instance['before_image'] : '';
$image = isset( $instance['image'] ) ? $instance['image'] : $image_keys[0];
$after_image = isset( $instance['after_image'] ) ? $instance['after_image'] : '';
// Widget admin form.
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'inventory-presser' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'before_image' ) ); ?>"><?php esc_html_e( 'Text before image:', 'inventory-presser' ); ?></label>
<textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'before_image' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'before_image' ) ); ?>"><?php echo esc_attr( $before_image ); ?></textarea>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'image' ) ); ?>"><?php esc_html_e( 'Image:', 'inventory-presser' ); ?></label>
<select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'image' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'image' ) ); ?>">
<?php
foreach ( $this->images() as $key => $imginfo ) {
printf(
'<option value="%s"%s>%s</option>',
esc_attr( $key ),
selected( $key === $image, true, false ),
esc_html( $imginfo['text'] )
);
}
?>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'after_image' ) ); ?>"><?php esc_html_e( 'Text after image:', 'inventory-presser' ); ?></label>
<textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'after_image' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'after_image' ) ); ?>"><?php echo esc_attr( $after_image ); ?></textarea>
</p>
<?php
}
Expand full source codeCollapse full source codeView on Github