Image Widget - Version 4.4

Version Description

  • Feature - Add srcset and size attribute support (props @philwp)
  • Tweak - Readme adjustments
  • Tweak - Additional refinements to notice code.
Download this release

Release Info

Developer zbtirrell
Plugin Icon 128x128 Image Widget
Version 4.4
Comparing to
See all releases

Code changes from version 4.3.1 to 4.4

Files changed (3) hide show
  1. image-widget.php +131 -42
  2. lang/image-widget.pot +30 -21
  3. readme.txt +14 -8
image-widget.php CHANGED
@@ -2,10 +2,10 @@
2
  /*
3
  Plugin Name: Image Widget
4
  Plugin URI: http://wordpress.org/plugins/image-widget/
5
- Description: A simple image widget that uses the native WordPress media manager to add image widgets to your site.
6
  Author: Modern Tribe, Inc.
7
- Version: 4.3.1
8
- Author URI: http://m.tri.be/26
9
  Text Domain: image-widget
10
  Domain Path: /lang
11
  */
@@ -26,10 +26,12 @@ add_action( 'widgets_init', 'tribe_load_image_widget' );
26
  **/
27
  class Tribe_Image_Widget extends WP_Widget {
28
 
29
- const VERSION = '4.3';
30
 
31
  const CUSTOM_IMAGE_SIZE_SLUG = 'tribe_image_widget_custom';
32
 
 
 
33
  /**
34
  * Tribe Image Widget constructor
35
  *
@@ -55,6 +57,7 @@ class Tribe_Image_Widget extends WP_Widget {
55
  add_action( 'admin_notices', array( $this, 'post_upgrade_nag' ) );
56
 
57
  add_action( 'network_admin_notices', array( $this, 'post_upgrade_nag' ) );
 
58
  }
59
 
60
  /**
@@ -185,28 +188,28 @@ class Tribe_Image_Widget extends WP_Widget {
185
  */
186
  public function admin_head() {
187
  ?>
188
- <style type="text/css">
189
- .uploader input.button {
190
- width: 100%;
191
- height: 34px;
192
- line-height: 33px;
193
- margin-top: 15px;
194
- }
195
- .tribe_preview .aligncenter {
196
- display: block;
197
- margin-left: auto !important;
198
- margin-right: auto !important;
199
- }
200
- .tribe_preview {
201
- overflow: hidden;
202
- max-height: 300px;
203
- }
204
- .tribe_preview img {
205
- margin: 10px 0;
206
- height: auto;
207
- }
208
- </style>
209
- <?php
210
  }
211
 
212
  /**
@@ -287,6 +290,16 @@ class Tribe_Image_Widget extends WP_Widget {
287
  $instance['width'] = $image_details[1];
288
  $instance['height'] = $image_details[2];
289
  }
 
 
 
 
 
 
 
 
 
 
290
  }
291
  $instance['width'] = abs( $instance['width'] );
292
  $instance['height'] = abs( $instance['height'] );
@@ -308,6 +321,12 @@ class Tribe_Image_Widget extends WP_Widget {
308
  if ( ! empty( $instance['align'] ) && $instance['align'] != 'none' ) {
309
  $attr['class'] .= " align{$instance['align']}";
310
  }
 
 
 
 
 
 
311
  $attr = apply_filters( 'image_widget_image_attributes', $attr, $instance );
312
 
313
  // If there is an imageurl, use it to render the image. Eventually we should kill this and simply rely on attachment_ids.
@@ -420,22 +439,92 @@ class Tribe_Image_Widget extends WP_Widget {
420
  public function post_upgrade_nag() {
421
  if ( ! current_user_can( 'install_plugins' ) ) return;
422
 
423
- $version_key = '_image_widget_version';
424
- if ( get_site_option( $version_key ) == self::VERSION ) return;
425
-
426
- ?>
427
- <div class="update-nag">
428
- <?php esc_html_e( 'Thanks for using the Image Widget by Modern Tribe! If you like these features, you\'ll love what we\'re working on next.', 'image-widget' );?>
429
- <br>
430
- <?php printf(
431
- esc_html__( 'Check out the new %1$sImage Widget Plus%2$s!', 'image-widget' ),
432
- '<a href="http://m.tri.be/19mb" target="_blank">',
433
- '</a>'
434
- ); ?>
435
- </div>
436
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
437
 
438
- update_site_option( $version_key, self::VERSION );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
439
  }
440
 
441
  /**
@@ -451,4 +540,4 @@ class Tribe_Image_Widget extends WP_Widget {
451
  }
452
  return $meta;
453
  }
454
- }
2
  /*
3
  Plugin Name: Image Widget
4
  Plugin URI: http://wordpress.org/plugins/image-widget/
5
+ Description: A simple image widget that uses the native WordPress media manager to add image widgets to your site. <strong>COMING SOON: <a href="http://theeventscalendar.org/products/image-widget-plus/?utm_campaign=in-app&utm_source=docblock&utm_medium=image-widget">Image Widget Plus</a> - Multiple images, slider and more.</strong>
6
  Author: Modern Tribe, Inc.
7
+ Version: 4.4
8
+ Author URI: http://m.tri.be/iwpdoc
9
  Text Domain: image-widget
10
  Domain Path: /lang
11
  */
26
  **/
27
  class Tribe_Image_Widget extends WP_Widget {
28
 
29
+ const VERSION = '4.4';
30
 
31
  const CUSTOM_IMAGE_SIZE_SLUG = 'tribe_image_widget_custom';
32
 
33
+ const VERSION_KEY = '_image_widget_version';
34
+
35
  /**
36
  * Tribe Image Widget constructor
37
  *
57
  add_action( 'admin_notices', array( $this, 'post_upgrade_nag' ) );
58
 
59
  add_action( 'network_admin_notices', array( $this, 'post_upgrade_nag' ) );
60
+ add_action( 'wp_ajax_dismissed_image_widget_notice_handler', array( $this, 'ajax_notice_handler' ) );
61
  }
62
 
63
  /**
188
  */
189
  public function admin_head() {
190
  ?>
191
+ <style type="text/css">
192
+ .uploader input.button {
193
+ width: 100%;
194
+ height: 34px;
195
+ line-height: 33px;
196
+ margin-top: 15px;
197
+ }
198
+ .tribe_preview .aligncenter {
199
+ display: block;
200
+ margin-left: auto !important;
201
+ margin-right: auto !important;
202
+ }
203
+ .tribe_preview {
204
+ overflow: hidden;
205
+ max-height: 300px;
206
+ }
207
+ .tribe_preview img {
208
+ margin: 10px 0;
209
+ height: auto;
210
+ }
211
+ </style>
212
+ <?php
213
  }
214
 
215
  /**
290
  $instance['width'] = $image_details[1];
291
  $instance['height'] = $image_details[2];
292
  }
293
+
294
+ $image_srcset = wp_get_attachment_image_srcset( $instance['attachment_id'], $size);
295
+ if ( $image_srcset ) {
296
+ $instance['srcset'] = $image_srcset;
297
+ }
298
+
299
+ $image_sizes = wp_get_attachment_image_sizes( $instance['attachment_id'], $size );
300
+ if ( $image_sizes ) {
301
+ $instance['sizes'] = $image_sizes;
302
+ }
303
  }
304
  $instance['width'] = abs( $instance['width'] );
305
  $instance['height'] = abs( $instance['height'] );
321
  if ( ! empty( $instance['align'] ) && $instance['align'] != 'none' ) {
322
  $attr['class'] .= " align{$instance['align']}";
323
  }
324
+ if ( !empty($instance['srcset'] ) ) {
325
+ $attr['srcset'] = $instance['srcset'];
326
+ }
327
+ if ( ! empty($instance['sizes'] ) ) {
328
+ $attr['sizes'] = $instance['sizes'];
329
+ }
330
  $attr = apply_filters( 'image_widget_image_attributes', $attr, $instance );
331
 
332
  // If there is an imageurl, use it to render the image. Eventually we should kill this and simply rely on attachment_ids.
439
  public function post_upgrade_nag() {
440
  if ( ! current_user_can( 'install_plugins' ) ) return;
441
 
442
+ global $pagenow;
443
+ $msg = false;
444
+ switch ( $pagenow ) {
445
+ case 'plugins.php' :
446
+ $msg = $this->upgrade_nag_plugins_admin_msg();
447
+ break;
448
+ case 'widgets.php' :
449
+ $msg = $this->upgrade_nag_widget_admin_msg();
450
+ break;
451
+ }
452
+
453
+ if ( !$msg ) return;
454
+
455
+ echo $msg;
456
+ ?><script>
457
+ jQuery(document).ready(function($){
458
+ // Dismiss our admin notice
459
+ $( document ).on( 'click', '.image-widget-notice .notice-dismiss', function () {
460
+ var key = $( this ).closest( '.image-widget-notice' ).data( 'key' );
461
+ $.ajax( ajaxurl,
462
+ {
463
+ type: 'POST',
464
+ data: {
465
+ action: 'dismissed_image_widget_notice_handler',
466
+ key: key
467
+ }
468
+ } );
469
+ } );
470
+ } );
471
+ </script><?php
472
+ }
473
 
474
+ /**
475
+ * AJAX handler to store the state of dismissible notices.
476
+ */
477
+ function ajax_notice_handler() {
478
+ if ( empty( $_POST['key'] ) ) return;
479
+ $key = $this->generate_key( sanitize_text_field( $_POST['key'] ) );
480
+ update_site_option( $key, self::VERSION );
481
+ }
482
+
483
+ /**
484
+ * Generate version key for admin notice options
485
+ *
486
+ * @param string $key
487
+ * @return string option key
488
+ */
489
+ private function generate_key( $key ) {
490
+ $option_key = join( "_", array(
491
+ self::VERSION_KEY,
492
+ $key
493
+ ) );
494
+ return $option_key;
495
+ }
496
+
497
+ /**
498
+ * Upgrade nag: Plugins Admin
499
+ *
500
+ * @return string alert message.
501
+ */
502
+ private function upgrade_nag_plugins_admin_msg() {
503
+ $key = "plugin";
504
+ $option_key = $this->generate_key( $key );
505
+ if ( get_site_option( $option_key ) == self::VERSION ) return;
506
+ $msg = sprintf(
507
+ __( '<p class="dashicons-before dashicons-format-gallery"><strong><a href="%s" target="_blank">Image Widget Plus</a></strong> is coming soon! Add random images, lightbox, and slider - <strong><a href="%s">Sign up now for early access.</a></strong></p>','image-widget' ),
508
+ 'http://m.tri.be/19my',
509
+ 'http://m.tri.be/19my'
510
+ );
511
+ return "<div class='notice notice-info is-dismissible image-widget-notice' data-key='$key'>$msg</div>";
512
+ }
513
+
514
+ /**
515
+ * Upgrade nag: Widget Admin
516
+ *
517
+ * @return string alert message.
518
+ */
519
+ private function upgrade_nag_widget_admin_msg() {
520
+ $key = "widget";
521
+ $option_key = $this->generate_key( $key );
522
+ if ( get_site_option( $option_key ) == self::VERSION ) return;
523
+ $msg = sprintf(
524
+ __( '<p class="dashicons-before dashicons-star-filled"><strong>Image Widget Plus</strong> - Add lightbox, slideshow, and random image widgets. <strong><a href="%s" target="_blank">Find out how!</a></strong></p>','image-widget' ),
525
+ 'http://m.tri.be/19mx'
526
+ );
527
+ return "<div class='notice notice-info is-dismissible image-widget-notice' data-key='$key'>$msg</div>";
528
  }
529
 
530
  /**
540
  }
541
  return $meta;
542
  }
543
+ }
lang/image-widget.pot CHANGED
@@ -3,7 +3,7 @@ msgid ""
3
  msgstr ""
4
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
  "Project-Id-Version: Image Widget\n"
6
- "POT-Creation-Date: 2017-03-20 08:23-0400\n"
7
  "PO-Revision-Date: 2017-03-17 17:01-0400\n"
8
  "Last-Translator: \n"
9
  "Language-Team: \n"
@@ -15,64 +15,70 @@ msgstr ""
15
  "X-Poedit-WPHeader: image-widget.php\n"
16
  "X-Poedit-SourceCharset: UTF-8\n"
17
  "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
18
- "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
19
- "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
20
  "X-Poedit-SearchPath-0: .\n"
21
  "X-Poedit-SearchPathExcluded-0: *.js\n"
22
 
23
- #: image-widget.php:40
24
  msgid "Showcase a single image with a Title, URL, and a Description"
25
  msgstr ""
26
 
27
  #. Plugin Name of the plugin/theme
28
- #: image-widget.php:42
29
  msgid "Image Widget"
30
  msgstr ""
31
 
32
- #: image-widget.php:77 views/widget-admin.php:13
33
  msgid "Select an Image"
34
  msgstr ""
35
 
36
- #: image-widget.php:78 lib/ImageWidgetDeprecated.php:66
37
  msgid "Insert Into Widget"
38
  msgstr ""
39
 
40
- #: image-widget.php:346
41
  msgid "Full Size"
42
  msgstr ""
43
 
44
- #: image-widget.php:347
45
  msgid "Thumbnail"
46
  msgstr ""
47
 
48
- #: image-widget.php:348
49
  msgid "Medium"
50
  msgstr ""
51
 
52
- #: image-widget.php:349
53
  msgid "Large"
54
  msgstr ""
55
 
56
- #: image-widget.php:350
57
  msgid "Custom"
58
  msgstr ""
59
 
60
- #: image-widget.php:428
 
61
  msgid ""
62
- "Thanks for using the Image Widget by Modern Tribe! If you like these "
63
- "features, you'll love what we're working on next."
 
 
64
  msgstr ""
65
 
66
- #: image-widget.php:431
67
  #, php-format
68
- msgid "Check out the new %1$sImage Widget Plus%2$s!"
 
 
 
69
  msgstr ""
70
 
71
- #: image-widget.php:450
72
  msgid "Coming Soon:"
73
  msgstr ""
74
 
75
- #: image-widget.php:450
76
  msgid "Image Widget Plus"
77
  msgstr ""
78
 
@@ -166,7 +172,10 @@ msgstr ""
166
  #. Description of the plugin/theme
167
  msgid ""
168
  "A simple image widget that uses the native WordPress media manager to add "
169
- "image widgets to your site."
 
 
 
170
  msgstr ""
171
 
172
  #. Author of the plugin/theme
@@ -174,5 +183,5 @@ msgid "Modern Tribe, Inc."
174
  msgstr ""
175
 
176
  #. Author URI of the plugin/theme
177
- msgid "http://m.tri.be/26"
178
  msgstr ""
3
  msgstr ""
4
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
  "Project-Id-Version: Image Widget\n"
6
+ "POT-Creation-Date: 2017-04-17 09:33-0400\n"
7
  "PO-Revision-Date: 2017-03-17 17:01-0400\n"
8
  "Last-Translator: \n"
9
  "Language-Team: \n"
15
  "X-Poedit-WPHeader: image-widget.php\n"
16
  "X-Poedit-SourceCharset: UTF-8\n"
17
  "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
18
+ "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;"
19
+ "_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
20
  "X-Poedit-SearchPath-0: .\n"
21
  "X-Poedit-SearchPathExcluded-0: *.js\n"
22
 
23
+ #: image-widget.php:42
24
  msgid "Showcase a single image with a Title, URL, and a Description"
25
  msgstr ""
26
 
27
  #. Plugin Name of the plugin/theme
28
+ #: image-widget.php:44
29
  msgid "Image Widget"
30
  msgstr ""
31
 
32
+ #: image-widget.php:80 views/widget-admin.php:13
33
  msgid "Select an Image"
34
  msgstr ""
35
 
36
+ #: image-widget.php:81 lib/ImageWidgetDeprecated.php:66
37
  msgid "Insert Into Widget"
38
  msgstr ""
39
 
40
+ #: image-widget.php:365
41
  msgid "Full Size"
42
  msgstr ""
43
 
44
+ #: image-widget.php:366
45
  msgid "Thumbnail"
46
  msgstr ""
47
 
48
+ #: image-widget.php:367
49
  msgid "Medium"
50
  msgstr ""
51
 
52
+ #: image-widget.php:368
53
  msgid "Large"
54
  msgstr ""
55
 
56
+ #: image-widget.php:369
57
  msgid "Custom"
58
  msgstr ""
59
 
60
+ #: image-widget.php:507
61
+ #, php-format
62
  msgid ""
63
+ "<p class=\"dashicons-before dashicons-format-gallery\"><strong><a href=\"%s"
64
+ "\" target=\"_blank\">Image Widget Plus</a></strong> is coming soon! Add "
65
+ "random images, lightbox, and slider - <strong><a href=\"%s\">Sign up now "
66
+ "for early access.</a></strong></p>"
67
  msgstr ""
68
 
69
+ #: image-widget.php:524
70
  #, php-format
71
+ msgid ""
72
+ "<p class=\"dashicons-before dashicons-star-filled\"><strong>Image Widget "
73
+ "Plus</strong> - Add lightbox, slideshow, and random image widgets. "
74
+ "<strong><a href=\"%s\" target=\"_blank\">Find out how!</a></strong></p>"
75
  msgstr ""
76
 
77
+ #: image-widget.php:539
78
  msgid "Coming Soon:"
79
  msgstr ""
80
 
81
+ #: image-widget.php:539
82
  msgid "Image Widget Plus"
83
  msgstr ""
84
 
172
  #. Description of the plugin/theme
173
  msgid ""
174
  "A simple image widget that uses the native WordPress media manager to add "
175
+ "image widgets to your site. <strong>COMING SOON: <a href=\"http://"
176
+ "theeventscalendar.org/products/image-widget-plus/?utm_campaign=in-"
177
+ "app&utm_source=docblock&utm_medium=image-widget\">Image Widget Plus</a> - "
178
+ "Multiple images, slider and more.</strong>"
179
  msgstr ""
180
 
181
  #. Author of the plugin/theme
183
  msgstr ""
184
 
185
  #. Author URI of the plugin/theme
186
+ msgid "http://m.tri.be/iwpdoc"
187
  msgstr ""
readme.txt CHANGED
@@ -3,17 +3,17 @@ Contributors: ModernTribe, peterchester, borkweb, zbtirrell
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4BSPTNFFY6AL6
4
  Tags: widget, image, ad, banner, simple, upload, sidebar, admin, thickbox, resize, arabic, brazilian portuguese, dutch, german, hebrew, italian, japanese, polish, spanish, swedish, widget-only
5
  Requires at least: 3.5
6
- Tested up to: 4.4.2
7
- Stable tag: 4.3.1
8
 
9
  A simple image widget that uses the native WordPress media manager to add image widgets to your site.
10
 
11
  == Description ==
12
 
13
- Join over 500,000 sites running our classic Image Widget plugin!
14
-
15
  Image Widget is a simple plugin that uses the native WordPress media manager to add image widgets to your site.
16
 
 
 
17
  = Image Widget Features =
18
 
19
  * Responsive
@@ -32,7 +32,7 @@ Image Widget is developed and maintained by [Modern Tribe](http://m.tri.be/19md)
32
 
33
  This plugin is actively supported by our team and contributions from community members. If you see a question in the forum you can help with or have a great idea and want to code it up or submit a patch, that would be awesome! Not only will we shower you with praise and thanks, it’s also a good way to get to know us and lead into options for paid work if you freelance.
34
 
35
- = Coming Soon - Image Widget Plus =
36
 
37
  Looking for more features? Our [new Image Widget Plus plugin](http://m.tri.be/19mf) is coming soon!
38
 
@@ -60,7 +60,7 @@ Getting started with Image Widget is a breeze!
60
  1. Download and install the Image Widget plugin
61
  1. From your WordPress admin screen, select Plugins from the menu
62
  1. Activate the Image Widget plugin
63
- 1. Go to Appearance > Widget to place the widget
64
 
65
  If you run into any questions or have suggestions, please visit the forum to post questions or comments.
66
 
@@ -93,7 +93,7 @@ Though we do not have a demo available, we do have [screenshots available here](
93
 
94
  = How can I add lightbox, slider, or random image capabilities? =
95
 
96
- These features are part of our Image Widget Plus plugin. You can learn more about Image Widget Plus [on our website](http://m.tri.be/19mh).
97
 
98
  = Where do I go to file a bug or ask a question? =
99
 
@@ -207,9 +207,15 @@ For more info on the philosophy here, check out our [blog post](http://tri.be/de
207
 
208
  == Changelog ==
209
 
 
 
 
 
 
 
210
  = 4.3.1 =
211
 
212
- * Tweak - adjusted promotional text
213
 
214
  = 4.3 =
215
 
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4BSPTNFFY6AL6
4
  Tags: widget, image, ad, banner, simple, upload, sidebar, admin, thickbox, resize, arabic, brazilian portuguese, dutch, german, hebrew, italian, japanese, polish, spanish, swedish, widget-only
5
  Requires at least: 3.5
6
+ Tested up to: 4.7.3
7
+ Stable tag: 4.4
8
 
9
  A simple image widget that uses the native WordPress media manager to add image widgets to your site.
10
 
11
  == Description ==
12
 
 
 
13
  Image Widget is a simple plugin that uses the native WordPress media manager to add image widgets to your site.
14
 
15
+ Need to add slideshows, lightboxes, or random images? Check out [Image Widget Plus](http://m.tri.be/19mc)!
16
+
17
  = Image Widget Features =
18
 
19
  * Responsive
32
 
33
  This plugin is actively supported by our team and contributions from community members. If you see a question in the forum you can help with or have a great idea and want to code it up or submit a patch, that would be awesome! Not only will we shower you with praise and thanks, it’s also a good way to get to know us and lead into options for paid work if you freelance.
34
 
35
+ = Coming Soon - Image Widget Plus! =
36
 
37
  Looking for more features? Our [new Image Widget Plus plugin](http://m.tri.be/19mf) is coming soon!
38
 
60
  1. Download and install the Image Widget plugin
61
  1. From your WordPress admin screen, select Plugins from the menu
62
  1. Activate the Image Widget plugin
63
+ 1. Go to Appearance > Widget to place the widget in your sidebar in the Design
64
 
65
  If you run into any questions or have suggestions, please visit the forum to post questions or comments.
66
 
93
 
94
  = How can I add lightbox, slider, or random image capabilities? =
95
 
96
+ These features are part of our Image Widget Plus plugin. You can learn more about [Image Widget Plus](http://m.tri.be/19mh) on our website.
97
 
98
  = Where do I go to file a bug or ask a question? =
99
 
207
 
208
  == Changelog ==
209
 
210
+ = 4.4 =
211
+
212
+ * Feature - Add srcset and size attribute support (props @philwp)
213
+ * Tweak - Readme adjustments
214
+ * Tweak - Additional refinements to notice code.
215
+
216
  = 4.3.1 =
217
 
218
+ * Tweak - Upgrade admin notice code
219
 
220
  = 4.3 =
221