Simple Image Widget - Version 3.0.2

Version Description

  • Implemented feature for opening links in a new tab/window.
  • Fixed a bug preventing links in legacy widgets to not work.
Download this release

Release Info

Developer blazersix
Plugin Icon 128x128 Simple Image Widget
Version 3.0.2
Comparing to
See all releases

Code changes from version 3.0.1 to 3.0.2

class-simple-image-widget.php CHANGED
@@ -96,7 +96,8 @@ class Simple_Image_Widget extends WP_Widget {
96
  $link_open = '';
97
  $link_close = '';
98
  if ( ! empty ( $instance['link'] ) ) {
99
- $link_open = '<a href="' . esc_url( $instance['link'] ) . '">';
 
100
  $link_close = '</a>';
101
  }
102
 
@@ -120,10 +121,10 @@ class Simple_Image_Widget extends WP_Widget {
120
  } elseif ( ! empty( $instance['image'] ) ) {
121
  // Legacy output.
122
  $output .= sprintf( '%s<img src="%s" alt="%s">%s',
123
- $link_before,
124
  esc_url( $instance['image'] ),
125
  ( empty( $instance['alt'] ) ) ? '' : esc_attr( $instance['alt'] ),
126
- $link_after
127
  );
128
  }
129
 
@@ -156,6 +157,7 @@ class Simple_Image_Widget extends WP_Widget {
156
  'image_size' => 'full',
157
  'link' => '',
158
  'link_text' => '',
 
159
  'title' => '',
160
  'text' => '',
161
  ) );
@@ -243,10 +245,16 @@ class Simple_Image_Widget extends WP_Widget {
243
 
244
  case 'link' :
245
  ?>
246
- <p>
247
  <label for="<?php echo $this->get_field_id( 'link' ); ?>"><?php _e( 'Link:', 'simple-image-widget' ); ?></label>
248
  <input type="text" name="<?php echo $this->get_field_name( 'link' ); ?>" id="<?php echo $this->get_field_id( 'link' ); ?>" value="<?php echo esc_url( $instance['link'] ); ?>" class="widefat">
249
  </p>
 
 
 
 
 
 
250
  <?php
251
  break;
252
 
@@ -314,6 +322,7 @@ class Simple_Image_Widget extends WP_Widget {
314
  $instance['image_id'] = absint( $new_instance['image_id'] );
315
  $instance['link'] = esc_url_raw( $new_instance['link'] );
316
  $instance['link_text'] = wp_kses_data( $new_instance['link_text'] );
 
317
  $instance['text'] = wp_kses_data( $new_instance['text'] );
318
 
319
  $instance['image'] = esc_url_raw( $new_instance['image'] ); // Legacy image URL.
96
  $link_open = '';
97
  $link_close = '';
98
  if ( ! empty ( $instance['link'] ) ) {
99
+ $target = ( empty( $instance['new_window'] ) ) ? '' : ' target="_blank"';
100
+ $link_open = '<a href="' . esc_url( $instance['link'] ) . '"' . $target . '>';
101
  $link_close = '</a>';
102
  }
103
 
121
  } elseif ( ! empty( $instance['image'] ) ) {
122
  // Legacy output.
123
  $output .= sprintf( '%s<img src="%s" alt="%s">%s',
124
+ $link_open,
125
  esc_url( $instance['image'] ),
126
  ( empty( $instance['alt'] ) ) ? '' : esc_attr( $instance['alt'] ),
127
+ $link_close
128
  );
129
  }
130
 
157
  'image_size' => 'full',
158
  'link' => '',
159
  'link_text' => '',
160
+ 'new_window' => '',
161
  'title' => '',
162
  'text' => '',
163
  ) );
245
 
246
  case 'link' :
247
  ?>
248
+ <p style="margin-bottom: 0.25em">
249
  <label for="<?php echo $this->get_field_id( 'link' ); ?>"><?php _e( 'Link:', 'simple-image-widget' ); ?></label>
250
  <input type="text" name="<?php echo $this->get_field_name( 'link' ); ?>" id="<?php echo $this->get_field_id( 'link' ); ?>" value="<?php echo esc_url( $instance['link'] ); ?>" class="widefat">
251
  </p>
252
+ <p style="padding-left: 2px">
253
+ <label for="<?php echo $this->get_field_id( 'new_window' ); ?>">
254
+ <input type="checkbox" name="<?php echo $this->get_field_name( 'new_window' ); ?>" id="<?php echo $this->get_field_id( 'new_window' ); ?>" <?php checked( $instance['new_window'] ); ?>>
255
+ <?php _e( 'Open in new window?', 'simple-image-widget' ); ?>
256
+ </label>
257
+ </p>
258
  <?php
259
  break;
260
 
322
  $instance['image_id'] = absint( $new_instance['image_id'] );
323
  $instance['link'] = esc_url_raw( $new_instance['link'] );
324
  $instance['link_text'] = wp_kses_data( $new_instance['link_text'] );
325
+ $instance['new_window'] = isset( $new_instance['new_window'] );
326
  $instance['text'] = wp_kses_data( $new_instance['text'] );
327
 
328
  $instance['image'] = esc_url_raw( $new_instance['image'] ); // Legacy image URL.
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: blazersix, bradyvercher
3
  Tags: image widget, widget, media, media manager, sidebar, image, photo, picture
4
  Requires at least: 3.3
5
  Tested up to: 3.5
6
- Stable tag: 3.0.1
7
  License: GPL-2.0+
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -32,6 +32,10 @@ Read about the original thought behind creating this widget and ways it can be e
32
 
33
  == Changelog ==
34
 
 
 
 
 
35
  = 3.0.1 =
36
  * Removed the main plugin file for the previous version.
37
 
3
  Tags: image widget, widget, media, media manager, sidebar, image, photo, picture
4
  Requires at least: 3.3
5
  Tested up to: 3.5
6
+ Stable tag: 3.0.2
7
  License: GPL-2.0+
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
32
 
33
  == Changelog ==
34
 
35
+ = 3.0.2 =
36
+ * Implemented feature for opening links in a new tab/window.
37
+ * Fixed a bug preventing links in legacy widgets to not work.
38
+
39
  = 3.0.1 =
40
  * Removed the main plugin file for the previous version.
41
 
simple-image-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Simple Image Widget
4
  * Plugin URI: https://wordpress.org/extend/plugins/simple-image-widget/
5
  * Description: A simple image widget utilizing the new WordPress media manager.
6
- * Version: 3.0.1
7
  * Author: Blazer Six
8
  * Author URI: http://www.blazersix.com/
9
  * License: GPL-2.0+
3
  * Plugin Name: Simple Image Widget
4
  * Plugin URI: https://wordpress.org/extend/plugins/simple-image-widget/
5
  * Description: A simple image widget utilizing the new WordPress media manager.
6
+ * Version: 3.0.2
7
  * Author: Blazer Six
8
  * Author URI: http://www.blazersix.com/
9
  * License: GPL-2.0+