Inventory_Presser_Order_By_Widget::widget( array $args, array $instance )

Outputs the widget front-end HTML


Parameters Parameters

$args

(array) (Required)

$instance

(array) (Required)


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/widget/class-widget-order-by.php

	public function widget( $args, $instance ) {

		wp_enqueue_script( 'order-by-widget-javascript' );
		$title = apply_filters( 'widget_title', ( isset( $instance['title'] ) ? $instance['title'] : '' ) );

		$keys_to_list = explode( '|', $instance['post-meta-keys'] );
		if ( 0 < count( $keys_to_list ) ) {
			echo wp_kses_post( $args['before_widget'] );
			if ( $title ) {
				echo wp_kses_post( $args['before_title'] ) . esc_html( $title ) . wp_kses_post( $args['after_title'] );
			}
			echo '<ul class="order-by-list list-nostyle">';
			foreach ( $keys_to_list as $key ) {
				echo '<li><a href="javascript:order_by_post_meta(\'' . esc_attr( $key ) . '\');">'
				. esc_html( isset( $instance[ 'label-' . $key ] ) ? $instance[ 'label-' . $key ] : $key )
				. '</a></li>';
			}
			echo '</ul>' . wp_kses_post( $args['after_widget'] );
		}
	}