Inventory_Presser_Google_Maps_Widget_V3::form( array $instance )

form

Description Description

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


Top ↑

Parameters Parameters

$instance

(array) (Required)


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/widget/class-widget-google-maps-v3.php

	public function form( $instance ) {

		$title   = $instance['title'] ?? '';
		$api_key = $instance['api_key'] ?? '';

		// Title ?><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>
		<?php

		// API Key
		?>
		<p>
			<label for="<?php echo $this->get_field_id( 'api_key' ); ?>"><?php _e( 'API Key:', 'inventory-presser' ); ?></label>
			<input class="widefat" id="<?php echo $this->get_field_id( 'api_key' ); ?>" name="<?php echo $this->get_field_name( 'api_key' ); ?>" type="text" value="<?php echo esc_attr( $api_key ); ?>" />
			<p class="description">
			<?php

				printf(
					'%s <a href="%s">%s</a>',
					__( 'Obtain an API key at', 'inventory-presser' ),
					'https://developers.google.com/maps/documentation/javascript/get-api-key',
					__( 'Google Cloud Console', 'inventory-presser' )
				);

			?>
									</p>
		</p>
		<p><?php _e( 'Choose addresses to mark:', 'inventory-presser' ); ?></p>
												 <?php

													// get all location terms
													$location_terms = get_terms( 'location', array( 'hide_empty' => false ) );

													$location_slugs = isset( $instance['location_slugs'] ) ? $instance['location_slugs'] : array();
													if ( ! is_array( $location_slugs ) ) {
														$location_slugs = array( $location_slugs );
													}

													// loop through each location, set up form
													foreach ( $location_terms as $index => $term_object ) {
														printf(
															'<p><input id="%s" name="%s[]" value="%s" type="checkbox"%s> <label for="%s">%s</label></p>',
															$this->get_field_id( $term_object->slug ),
															$this->get_field_name( 'location_slugs' ),
															$term_object->slug,
															checked( in_array( $term_object->slug, $location_slugs ), true, false ),
															$this->get_field_id( $term_object->slug ),
															$term_object->description
														);
													}
	}