Image Widget - Version 4.4.3

Version Description

  • Fix - Fixed bug where selecting an image failed to trigger a Save & Publish in the Customizer (props to dsaric-dev for the fix)
  • Tweak - Roll-back to sidebar_admin_setup to enqueue resources for optimal plugin compatibility (props to megamenu for the heads up)
Download this release

Release Info

Developer borkweb
Plugin Icon 128x128 Image Widget
Version 4.4.3
Comparing to
See all releases

Code changes from version 4.4.2 to 4.4.3

Files changed (3) hide show
  1. image-widget.php +18 -13
  2. readme.txt +7 -2
  3. resources/js/image-widget.js +14 -3
image-widget.php CHANGED
@@ -4,7 +4,7 @@ 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><a href="http://m.tri.be/19my">Image Widget Plus</a> - Multiple images, slider and more.</strong>
6
  Author: Modern Tribe, Inc.
7
- Version: 4.4.2
8
  Author URI: http://m.tri.be/iwpdoc
9
  Text Domain: image-widget
10
  Domain Path: /lang
@@ -26,7 +26,7 @@ add_action( 'widgets_init', 'tribe_load_image_widget' );
26
  **/
27
  class Tribe_Image_Widget extends WP_Widget {
28
 
29
- const VERSION = '4.4.2';
30
 
31
  const CUSTOM_IMAGE_SIZE_SLUG = 'tribe_image_widget_custom';
32
 
@@ -47,9 +47,12 @@ class Tribe_Image_Widget extends WP_Widget {
47
  require_once( 'lib/ImageWidgetDeprecated.php' );
48
  new ImageWidgetDeprecated( $this );
49
  } else {
50
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_setup' ) );
51
  }
52
 
 
 
 
53
  add_action( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
54
 
55
  if ( ! defined( 'I_HAVE_SUPPORTED_THE_IMAGE_WIDGET' ) )
@@ -72,15 +75,6 @@ class Tribe_Image_Widget extends WP_Widget {
72
  * Enqueue all the javascript and CSS.
73
  */
74
  public function admin_setup() {
75
-
76
- // Only load on widget admin page and in the "Customizer" view.
77
- $screen = get_current_screen();
78
- $should_load = 'customize' == $screen->base || 'widgets' == $screen->base;
79
-
80
- if ( ! $should_load ) {
81
- return;
82
- }
83
-
84
  wp_enqueue_media();
85
 
86
  wp_enqueue_style( 'tribe-image-widget', plugins_url( 'resources/css/admin.css', __FILE__ ), array(), self::VERSION );
@@ -93,6 +87,17 @@ class Tribe_Image_Widget extends WP_Widget {
93
  ) );
94
  }
95
 
 
 
 
 
 
 
 
 
 
 
 
96
  /**
97
  * Widget frontend output
98
  *
@@ -537,4 +542,4 @@ class Tribe_Image_Widget extends WP_Widget {
537
  }
538
  return $meta;
539
  }
540
- }
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><a href="http://m.tri.be/19my">Image Widget Plus</a> - Multiple images, slider and more.</strong>
6
  Author: Modern Tribe, Inc.
7
+ Version: 4.4.3
8
  Author URI: http://m.tri.be/iwpdoc
9
  Text Domain: image-widget
10
  Domain Path: /lang
26
  **/
27
  class Tribe_Image_Widget extends WP_Widget {
28
 
29
+ const VERSION = '4.4.3';
30
 
31
  const CUSTOM_IMAGE_SIZE_SLUG = 'tribe_image_widget_custom';
32
 
47
  require_once( 'lib/ImageWidgetDeprecated.php' );
48
  new ImageWidgetDeprecated( $this );
49
  } else {
50
+ add_action( 'sidebar_admin_setup', array( $this, 'admin_setup' ) );
51
  }
52
 
53
+ // fire admin_setup if we are in the customizer
54
+ add_action( 'admin_enqueue_scripts', array( $this, 'maybe_admin_setup' ) );
55
+
56
  add_action( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
57
 
58
  if ( ! defined( 'I_HAVE_SUPPORTED_THE_IMAGE_WIDGET' ) )
75
  * Enqueue all the javascript and CSS.
76
  */
77
  public function admin_setup() {
 
 
 
 
 
 
 
 
 
78
  wp_enqueue_media();
79
 
80
  wp_enqueue_style( 'tribe-image-widget', plugins_url( 'resources/css/admin.css', __FILE__ ), array(), self::VERSION );
87
  ) );
88
  }
89
 
90
+ public function maybe_admin_setup() {
91
+ // Only load on widget admin page and in the "Customizer" view.
92
+ $screen = get_current_screen();
93
+
94
+ if ( 'customize' !== $screen->base ) {
95
+ return;
96
+ }
97
+
98
+ $this->admin_setup();
99
+ }
100
+
101
  /**
102
  * Widget frontend output
103
  *
542
  }
543
  return $meta;
544
  }
545
+ }
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Image Widget ===
2
- 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, retina, 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.2
8
 
9
  A simple image widget that uses the native WordPress media manager to add image widgets to your site.
10
 
@@ -206,6 +206,11 @@ For more info on the philosophy here, check out our [blog post](http://tri.be/de
206
 
207
  == Changelog ==
208
 
 
 
 
 
 
209
  = 4.4.2 =
210
 
211
  * Fix - fixed compatibility with WordPress versions prior to 4.4
1
  === Image Widget ===
2
+ Contributors: ModernTribe, peterchester, borkweb, zbtirrell, aguseo, barry.hughes, cliffpaulick, courane01, GeoffBel, ggwicz, jentheo, neillmcshea, nicosantos, shelbelliott, tribecari, trishasalas, vicskf
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, retina, 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.3
8
 
9
  A simple image widget that uses the native WordPress media manager to add image widgets to your site.
10
 
206
 
207
  == Changelog ==
208
 
209
+ = 4.4.3 =
210
+
211
+ * Fix - Fixed bug where selecting an image failed to trigger a Save & Publish in the Customizer (props to dsaric-dev for the fix)
212
+ * Tweak - Roll-back to sidebar_admin_setup to enqueue resources for optimal plugin compatibility (props to megamenu for the heads up)
213
+
214
  = 4.4.2 =
215
 
216
  * Fix - fixed compatibility with WordPress versions prior to 4.4
resources/js/image-widget.js CHANGED
@@ -30,12 +30,23 @@ jQuery(document).ready(function($){
30
  // Output Image preview and populate widget form.
31
  render : function( widget_id, widget_id_string, attachment ) {
32
 
 
 
 
33
  $("#" + widget_id_string + 'preview').html(imageWidget.imgHTML( attachment ));
34
 
35
  $("#" + widget_id_string + 'fields').slideDown();
36
 
37
- $("#" + widget_id_string + 'attachment_id').val(attachment.id);
38
- $("#" + widget_id_string + 'imageurl').val(attachment.url);
 
 
 
 
 
 
 
 
39
  $("#" + widget_id_string + 'aspect_ratio').val(attachment.width/attachment.height);
40
  $("#" + widget_id_string + 'width').val(attachment.width);
41
  $("#" + widget_id_string + 'height').val(attachment.height);
@@ -104,4 +115,4 @@ jQuery(document).ready(function($){
104
 
105
  };
106
 
107
- });
30
  // Output Image preview and populate widget form.
31
  render : function( widget_id, widget_id_string, attachment ) {
32
 
33
+ var $attachment_id = $( document.getElementById( widget_id_string + 'attachment_id' ) );
34
+ var $image_url = $( document.getElementById( widget_id_string + 'image_url' ) );
35
+
36
  $("#" + widget_id_string + 'preview').html(imageWidget.imgHTML( attachment ));
37
 
38
  $("#" + widget_id_string + 'fields').slideDown();
39
 
40
+ // update the attachment id if it has changed
41
+ if ( $attachment_id.val() !== attachment.id ) {
42
+ $attachment_id.val( attachment.id ).trigger( 'change' );
43
+ }
44
+
45
+ // update the url if it has changed
46
+ if ( $image_url.val() !== attachment.url ) {
47
+ $image_url.val( attachment.url ).trigger( 'change' );
48
+ }
49
+
50
  $("#" + widget_id_string + 'aspect_ratio').val(attachment.width/attachment.height);
51
  $("#" + widget_id_string + 'width').val(attachment.width);
52
  $("#" + widget_id_string + 'height').val(attachment.height);
115
 
116
  };
117
 
118
+ });