A_Z_Widget::form( Array $instance )

Print-out the configuration form for the widget.


Description


Parameters

$instance

(Array) (Required) Widget instance as provided by WordPress core.


Return

(void)


Source

File: widgets/class-a-z-widget.php

	function form( $instance ) {
		$title = $instance['title'];
		$title_id = $this->get_field_id( 'title' );
		$title_name = $this->get_field_name( 'title' );

		$post = isset( $instance['post'] ) ? $instance['post'] : ( isset( $instance['page'] ) ? $instance['page'] : 0 );
		$post_id = $this->get_field_id( 'post' );
		$post_name = $this->get_field_name( 'post' );

		$post_type = isset( $instance['post_type'] ) ? $instance['post_type'] : 'page';
		$post_type_id = $this->get_field_id( 'post_type' );
		$post_type_name = $this->get_field_name( 'post_type' );
		?>
		<div><label for="<?php echo esc_attr( $title_id ); ?>">
				<?php esc_html_e( 'Widget Title', 'a-z-listing' ); ?>
			</label></div>
		<input class="widefat" type="text"
			   id="<?php echo esc_attr( $title_id ); ?>"
			   name="<?php echo esc_attr( $title_name ); ?>"
			   placeholder="<?php esc_attr_e( 'Widget Title', 'a-z-listing' ); ?>"
			   value="<?php echo esc_attr( $title ); ?>" />

		<p style="color: #333;">
			<?php esc_html_e( 'Leave the title field blank, above, to use the title from the page set in the next field', 'a-z-listing' ); ?>
		</p>

		<div><label for="<?php echo esc_attr( $post_id ); ?>">
				<?php esc_html_e( 'Site map A-Z page', 'a-z-listing' ); ?>
			</label></div>
		<?php
		wp_dropdown_pages( array(
			'id' => intval( $post_id ),
			'name' => esc_html( $post_name ),
			'selected' => intval( $post ),
		) );
		?>

		<div><label for="<?php echo esc_attr( $post_type_id ); ?>">
				<?php esc_html_e( 'Post-type to display', 'a-z-listing' ); ?>
			</label></div>
		<?php
		$post_types = get_post_types();
		sort( $post_types );
		?>
		<select id="<?php echo esc_attr( $post_type_id ); ?>" name="<?php echo esc_attr( $post_type_name ); ?>">
			<?php foreach ( $post_types as $t ) : ?>
				<option value="<?php echo esc_attr( $t ); ?>" <?php if ( $post_type === $t ) { echo 'selected'; } ?>>
					<?php echo esc_html( $t ); ?>
				</option>
			<?php endforeach; ?>
		</select>
		<?php
	}

Changelog

Changelog
Version Description
0.1 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.