form.php
80 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Jetpack_Gallery_Widget backend settings form output. |
| 4 | * |
| 5 | * @package automattic/jetpack |
| 6 | */ |
| 7 | |
| 8 | // phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable |
| 9 | ?> |
| 10 | <p> |
| 11 | <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'jetpack' ); ?> |
| 12 | <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" |
| 13 | type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" /> |
| 14 | </label> |
| 15 | </p> |
| 16 | |
| 17 | <p> |
| 18 | <label> |
| 19 | <?php esc_html_e( 'Images:', 'jetpack' ); ?> |
| 20 | </label> |
| 21 | </p> |
| 22 | |
| 23 | <div class="gallery-widget-thumbs-wrapper"> |
| 24 | <div class="gallery-widget-thumbs"> |
| 25 | <?php |
| 26 | |
| 27 | // Add the thumbnails to the widget box. |
| 28 | $attachments = $this->get_attachments( $instance ); |
| 29 | |
| 30 | foreach ( $attachments as $attachment ) { |
| 31 | $url = add_query_arg( |
| 32 | array( |
| 33 | 'w' => self::THUMB_SIZE, |
| 34 | 'h' => self::THUMB_SIZE, |
| 35 | 'crop' => 'true', |
| 36 | ), |
| 37 | wp_get_attachment_url( $attachment->ID ) |
| 38 | ); |
| 39 | |
| 40 | ?> |
| 41 | |
| 42 | <img src="<?php echo esc_url( $url ); ?>" title="<?php echo esc_attr( $attachment->post_title ); ?>" alt="<?php echo esc_attr( $attachment->post_title ); ?>" |
| 43 | width="<?php echo esc_attr( self::THUMB_SIZE ); ?>" height="<?php echo esc_attr( self::THUMB_SIZE ); ?>" class="thumb" /> |
| 44 | <?php } ?> |
| 45 | </div> |
| 46 | |
| 47 | <div style="clear: both;"></div> |
| 48 | </div> |
| 49 | |
| 50 | <p> |
| 51 | <a class="button gallery-widget-choose-images"><span class="wp-media-buttons-icon"></span> <?php esc_html_e( 'Choose Images', 'jetpack' ); ?></a> |
| 52 | </p> |
| 53 | |
| 54 | <p class="gallery-widget-link-wrapper"> |
| 55 | <label for="<?php echo esc_attr( $this->get_field_id( 'link' ) ); ?>"><?php esc_html_e( 'Link To:', 'jetpack' ); ?></label> |
| 56 | <select name="<?php echo esc_attr( $this->get_field_name( 'link' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'link' ) ); ?>" class="widefat"> |
| 57 | <?php foreach ( $allowed_values['link'] as $key => $label ) : ?> |
| 58 | <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $instance['link'], $key ); ?>><?php echo esc_html( $label ); ?></option> |
| 59 | <?php endforeach; ?> |
| 60 | </select> |
| 61 | </p> |
| 62 | |
| 63 | <p> |
| 64 | <label for="<?php echo esc_attr( $this->get_field_id( 'random' ) ); ?>"><?php esc_html_e( 'Random Order:', 'jetpack' ); ?></label> |
| 65 | <input name="<?php echo esc_attr( $this->get_field_name( 'random' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'random' ) ); ?>" type="checkbox"<?php checked( ! empty( $instance['random'] ) ); ?>> |
| 66 | </p> |
| 67 | |
| 68 | <p class="gallery-widget-style-wrapper"> |
| 69 | <label for="<?php echo esc_attr( $this->get_field_id( 'type' ) ); ?>"><?php esc_html_e( 'Style:', 'jetpack' ); ?></label> |
| 70 | <select name="<?php echo esc_attr( $this->get_field_name( 'type' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'type' ) ); ?>" class="widefat gallery-widget-style"> |
| 71 | <?php foreach ( $allowed_values['type'] as $key => $label ) : ?> |
| 72 | <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $instance['type'], $key ); ?>><?php echo esc_html( $label ); ?></option> |
| 73 | <?php endforeach; ?> |
| 74 | </select> |
| 75 | </p> |
| 76 | |
| 77 | |
| 78 | <?php // Hidden input to hold the selected image ids as a csv list. ?> |
| 79 | <input type="hidden" class="gallery-widget-ids" name="<?php echo esc_attr( $this->get_field_name( 'ids' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'ids' ) ); ?>" value="<?php echo esc_attr( $instance['ids'] ); ?>" /> |
| 80 |