Inventory_Presser_Maximum_Price_Filter::form( array $instance )

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


Parameters Parameters

$instance

(array) (Required)


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/widget/class-widget-maximum-price-filter.php

	public function form( $instance ) {

		$title              = isset( $instance['title'] ) ? $instance['title'] : __( 'Price Filter', 'inventory-presser' );
		$prices             = ( isset( $instance['prices'] ) && is_array( $instance['prices'] ) ) ? implode( ',', $instance['prices'] ) : implode( ',', $this->price_defaults );
		$display_type_slugs = array_keys( $this->display_types() );
		$display_type       = isset( $instance['display_type'] ) ? $instance['display_type'] : $display_type_slugs[0];
		$orientation_slugs  = array_keys( $this->orientations() );
		$orientation        = isset( $instance['orientation'] ) ? $instance['orientation'] : $orientation_slugs[0];

		// 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( 'prices' ) ); ?>"><?php esc_html_e( 'Price Points (separated by commas)', 'inventory-presser' ); ?></label>
		<textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'prices' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'prices' ) ); ?>"><?php echo esc_html( $prices ); ?></textarea>
		</p>
		<p>
			<label for="<?php echo esc_attr( $this->get_field_id( 'display_type' ) ); ?>"><?php esc_html_e( 'Display Format:', 'inventory-presser' ); ?></label>
			<select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'display_type' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'display_type' ) ); ?>">
		<?php
		foreach ( $this->display_types() as $key => $label ) {
			printf(
				'<option value="%s"%s>%s</option>',
				esc_attr( $key ),
				selected( $display_type === $key, true, false ),
				esc_html( $label )
			);
		}
		?>
			</select>
		</p>
		<p>
			<label for="<?php echo esc_attr( $this->get_field_id( 'orientation' ) ); ?>"><?php esc_html_e( 'Orientation:', 'inventory-presser' ); ?></label>
			<select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'orientation' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'orientation' ) ); ?>">
		<?php
		foreach ( $this->orientations() as $key => $label ) {
			printf(
				'<option value="%s"%s>%s</option>',
				esc_attr( $key ),
				selected( $orientation == $key, true, false ),
				esc_html( $label )
			);
		}
		?>
			</select>
		</p>
		<p>
		<label for="<?php echo esc_attr( $this->get_field_id( 'cb_reset_link_only' ) ); ?>"><?php esc_html_e( 'Show Reset Link Only', 'inventory-presser' ); ?></label>
		<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'cb_reset_link_only' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'cb_reset_link_only' ) ); ?>" value="true"<?php checked( 'true', ( isset( $instance['cb_reset_link_only'] ) ? $instance['cb_reset_link_only'] : '' ) ); ?>>
		</p>
		<?php
	}