Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 46 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
||
| 1 | <?php |
| 2 | /** |
| 3 | * Jetpack_Gallery_Widget backend settings form output. |
| 4 | * |
| 5 | * @html-template Jetpack_Gallery_Widget::form |
| 6 | * @package automattic/jetpack |
| 7 | */ |
| 8 | |
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | exit( 0 ); |
| 11 | } |
| 12 | |
| 13 | // phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable -- HTML template, let Phan handle it. |
| 14 | |
| 15 | ?> |
| 16 | <p> |
| 17 | <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'jetpack' ); ?> |
| 18 | <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" |
| 19 | type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" /> |
| 20 | </label> |
| 21 | </p> |
| 22 | |
| 23 | <p> |
| 24 | <label> |
| 25 | <?php esc_html_e( 'Images:', 'jetpack' ); ?> |
| 26 | </label> |
| 27 | </p> |
| 28 | |
| 29 | <div class="gallery-widget-thumbs-wrapper"> |
| 30 | <div class="gallery-widget-thumbs"> |
| 31 | <?php |
| 32 | |
| 33 | // Add the thumbnails to the widget box. |
| 34 | $attachments = $this->get_attachments( $instance ); |
| 35 | |
| 36 | foreach ( $attachments as $attachment ) { |
| 37 | $url = add_query_arg( |
| 38 | array( |
| 39 | 'w' => self::THUMB_SIZE, |
| 40 | 'h' => self::THUMB_SIZE, |
| 41 | 'crop' => 'true', |
| 42 | ), |
| 43 | wp_get_attachment_url( $attachment->ID ) |
| 44 | ); |
| 45 | |
| 46 | ?> |
| 47 | |
| 48 | <img src="<?php echo esc_url( $url ); ?>" title="<?php echo esc_attr( $attachment->post_title ); ?>" alt="<?php echo esc_attr( $attachment->post_title ); ?>" |
| 49 | width="<?php echo (int) self::THUMB_SIZE; // @phan-suppress-current-line PhanRedundantCondition -- phpcs wants an explicit cast, phan complains it's redundant. 🤷 ?>" height="<?php echo (int) self::THUMB_SIZE; ?>" class="thumb" /> |
| 50 | <?php } ?> |
| 51 | </div> |
| 52 | |
| 53 | <div style="clear: both;"></div> |
| 54 | </div> |
| 55 | |
| 56 | <p> |
| 57 | <a class="button gallery-widget-choose-images"><span class="wp-media-buttons-icon"></span> <?php esc_html_e( 'Choose Images', 'jetpack' ); ?></a> |
| 58 | </p> |
| 59 | |
| 60 | <p class="gallery-widget-link-wrapper"> |
| 61 | <label for="<?php echo esc_attr( $this->get_field_id( 'link' ) ); ?>"><?php esc_html_e( 'Link To:', 'jetpack' ); ?></label> |
| 62 | <select name="<?php echo esc_attr( $this->get_field_name( 'link' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'link' ) ); ?>" class="widefat"> |
| 63 | <?php foreach ( $allowed_values['link'] as $key => $label ) : ?> |
| 64 | <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $instance['link'], $key ); ?>><?php echo esc_html( $label ); ?></option> |
| 65 | <?php endforeach; ?> |
| 66 | </select> |
| 67 | </p> |
| 68 | |
| 69 | <p> |
| 70 | <label for="<?php echo esc_attr( $this->get_field_id( 'random' ) ); ?>"><?php esc_html_e( 'Random Order:', 'jetpack' ); ?></label> |
| 71 | <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'] ) ); ?>> |
| 72 | </p> |
| 73 | |
| 74 | <p class="gallery-widget-style-wrapper"> |
| 75 | <label for="<?php echo esc_attr( $this->get_field_id( 'type' ) ); ?>"><?php esc_html_e( 'Style:', 'jetpack' ); ?></label> |
| 76 | <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"> |
| 77 | <?php foreach ( $allowed_values['type'] as $key => $label ) : ?> |
| 78 | <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $instance['type'], $key ); ?>><?php echo esc_html( $label ); ?></option> |
| 79 | <?php endforeach; ?> |
| 80 | </select> |
| 81 | </p> |
| 82 | |
| 83 | |
| 84 | <?php // Hidden input to hold the selected image ids as a csv list. ?> |
| 85 | <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'] ); ?>" /> |