form.php 3.1 KB

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