Inventory_Presser_Map_Widget::form( array $instance )
Outputs the widget settings form that is shown in the dashboard.
On This Page
Parameters Parameters
- $instance
-
(array) (Required)
Return Return
(void)
Source Source
File: includes/widget/class-widget-map.php
public function form( $instance ) { $title = isset( $instance['title'] ) ? $instance['title'] : ''; ?> <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> <?php esc_html_e( 'Choose addresses to include:', 'inventory-presser' ); ?> </p> <?php // get all location terms. $location_terms = get_terms( array( 'taxonomy' => 'location', 'hide_empty' => false, ) ); $location_slug = isset( $instance['location_slug'] ) ? $instance['location_slug'] : array(); if ( ! is_array( $location_slug ) ) { $location_slug = array( $location_slug ); } // loop through each location, set up form. foreach ( $location_terms as $index => $term_object ) { printf( '<p><input id="%1$s" name="%2$s[]" value="%3$s" type="checkbox"%4$s> <label for="%1$s">%5$s</label></p>', esc_attr( $this->get_field_id( $term_object->slug ) ), esc_attr( $this->get_field_name( 'location_slug' ) ), esc_attr( $term_object->slug ), checked( true, in_array( $term_object->slug, $location_slug, true ), false ), esc_html( str_replace( "\r", '', str_replace( PHP_EOL, ', ', $term_object->description ) ) ) ); } // Only show this if the API key is missing. $settings = INVP::settings(); if ( empty( $settings['mapbox_public_token'] ) ) { printf( '<p>%s</p>', esc_html__( 'An API token from mapbox.com is required for this widget to work. Obtain a key at mapbox.com and save it on the Inventory Presser Options page.', 'inventory-presser' ) ); } }
Expand full source codeCollapse full source codeView on Github