Inventory_Presser_KBB_Widget::form( array $instance )

form


Description

Outputs the widget settings form that is shown in the dashboard.


Parameters

$instance

(array) (Required)


Return

(void)


Source

File: includes/widget/class-widget-kbb.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 $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'inventory-presser' ); ?></label>
		<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
		</p>
		<p>
		<label for="<?php echo $this->get_field_id( 'before_image' ); ?>"><?php _e( 'Text before image:', 'inventory-presser' ); ?></label>
		<textarea class="widefat" id="<?php echo $this->get_field_id( 'before_image' ); ?>" name="<?php echo $this->get_field_name( 'before_image' ); ?>"><?php echo esc_attr( $before_image ); ?></textarea>
		</p>
		<p>
		<label for="<?php echo $this->get_field_id( 'image' ); ?>"><?php _e( 'Image:', 'inventory-presser' ); ?></label>

		<select class="widefat" id="<?php echo $this->get_field_id( 'image' ); ?>" name="<?php echo $this->get_field_name( 'image' ); ?>">
		<?php
		foreach ( $this->images() as $key => $imginfo ) {
			printf(
				'<option value="%s"%s>%s</option>',
				$key,
				selected( $key == $image, true, false ),
				$imginfo['text']
			);
		}
		?>
		</select>

		</p>

		<p>
		<label for="<?php echo $this->get_field_id( 'after_image' ); ?>"><?php _e( 'Text after image:', 'inventory-presser' ); ?></label>
		<textarea class="widefat" id="<?php echo $this->get_field_id( 'after_image' ); ?>" name="<?php echo $this->get_field_name( 'after_image' ); ?>"><?php echo esc_attr( $after_image ); ?></textarea>
		</p>
		<?php
	}