Image Widget - Version 4.3

Version Description

  • Translations - fixed compatibility with translate.wordpress.org
  • Translations - restored the pot file for easier community translations
  • Tweak - fixed a typo
  • Tweak - Minor code cleanup
Download this release

Release Info

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

Code changes from version 4.2.2 to 4.3

image-widget.php CHANGED
@@ -1,444 +1,445 @@
1
- <?php
2
- /*
3
- Plugin Name: Image Widget
4
- Plugin URI: http://wordpress.org/extend/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.2.2
8
- Author URI: http://m.tri.be/26
9
- */
10
-
11
- // Block direct requests
12
- if ( !defined('ABSPATH') ) {
13
- die('-1');
14
- }
15
-
16
- // Load the widget on widgets_init
17
- function tribe_load_image_widget() {
18
- register_widget('Tribe_Image_Widget');
19
- }
20
- add_action('widgets_init', 'tribe_load_image_widget');
21
-
22
- /**
23
- * Tribe_Image_Widget class
24
- **/
25
- class Tribe_Image_Widget extends WP_Widget {
26
-
27
- const VERSION = '4.2.2';
28
-
29
- const CUSTOM_IMAGE_SIZE_SLUG = 'tribe_image_widget_custom';
30
-
31
- /**
32
- * Tribe Image Widget constructor
33
- *
34
- * @author Modern Tribe, Inc.
35
- */
36
- public function __construct() {
37
- load_plugin_textdomain( 'image_widget', false, trailingslashit(basename(dirname(__FILE__))) . 'lang/');
38
- $widget_ops = array( 'classname' => 'widget_sp_image', 'description' => __( 'Showcase a single image with a Title, URL, and a Description', 'image_widget' ) );
39
- $control_ops = array( 'id_base' => 'widget_sp_image' );
40
- parent::__construct('widget_sp_image', __('Image Widget', 'image_widget'), $widget_ops, $control_ops);
41
-
42
- if ( $this->use_old_uploader() ) {
43
- require_once( 'lib/ImageWidgetDeprecated.php' );
44
- new ImageWidgetDeprecated( $this );
45
- } else {
46
- add_action( 'sidebar_admin_setup', array( $this, 'admin_setup' ) );
47
- }
48
- add_action( 'admin_head-widgets.php', array( $this, 'admin_head' ) );
49
-
50
- add_action( 'plugin_row_meta', array( $this, 'plugin_row_meta' ),10 ,2 );
51
-
52
- if ( !defined('I_HAVE_SUPPORTED_THE_IMAGE_WIDGET') )
53
- add_action( 'admin_notices', array( $this, 'post_upgrade_nag') );
54
-
55
- add_action( 'network_admin_notices', array( $this, 'post_upgrade_nag') );
56
- }
57
-
58
- /**
59
- * Test to see if this version of WordPress supports the new image manager.
60
- * @return bool true if the current version of WordPress does NOT support the current image management tech.
61
- */
62
- private function use_old_uploader() {
63
- if ( defined( 'IMAGE_WIDGET_COMPATIBILITY_TEST' ) ) return true;
64
- return !function_exists('wp_enqueue_media');
65
- }
66
-
67
- /**
68
- * Enqueue all the javascript.
69
- */
70
- public function admin_setup() {
71
- wp_enqueue_media();
72
- wp_enqueue_script( 'tribe-image-widget', plugins_url('resources/js/image-widget.js', __FILE__), array( 'jquery', 'media-upload', 'media-views' ), self::VERSION );
73
-
74
- wp_localize_script( 'tribe-image-widget', 'TribeImageWidget', array(
75
- 'frame_title' => __( 'Select an Image', 'image_widget' ),
76
- 'button_title' => __( 'Insert Into Widget', 'image_widget' ),
77
- ) );
78
- }
79
-
80
- /**
81
- * Widget frontend output
82
- *
83
- * @param array $args
84
- * @param array $instance
85
- * @author Modern Tribe, Inc.
86
- */
87
- public function widget( $args, $instance ) {
88
- extract( $args );
89
- $instance = wp_parse_args( (array) $instance, self::get_defaults() );
90
- if ( !empty( $instance['imageurl'] ) || !empty( $instance['attachment_id'] ) ) {
91
-
92
- $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'] );
93
- $instance['description'] = apply_filters( 'widget_text', $instance['description'], $args, $instance );
94
- $instance['link'] = apply_filters( 'image_widget_image_link', esc_url( $instance['link'] ), $args, $instance );
95
- $instance['linkid'] = apply_filters( 'image_widget_image_link_id', esc_attr( $instance['linkid'] ), $args, $instance );
96
- $instance['linktarget'] = apply_filters( 'image_widget_image_link_target', esc_attr( $instance['linktarget'] ), $args, $instance );
97
- $instance['width'] = apply_filters( 'image_widget_image_width', abs( $instance['width'] ), $args, $instance );
98
- $instance['height'] = apply_filters( 'image_widget_image_height', abs( $instance['height'] ), $args, $instance );
99
- $instance['maxwidth'] = apply_filters( 'image_widget_image_maxwidth', esc_attr( $instance['maxwidth'] ), $args, $instance );
100
- $instance['maxheight'] = apply_filters( 'image_widget_image_maxheight', esc_attr( $instance['maxheight'] ), $args, $instance );
101
- $instance['align'] = apply_filters( 'image_widget_image_align', esc_attr( $instance['align'] ), $args, $instance );
102
- $instance['alt'] = apply_filters( 'image_widget_image_alt', esc_attr( $instance['alt'] ), $args, $instance );
103
- $instance['rel'] = apply_filters( 'image_widget_image_rel', esc_attr( $instance['rel'] ), $args, $instance );
104
-
105
- if ( !defined( 'IMAGE_WIDGET_COMPATIBILITY_TEST' ) ) {
106
- $instance['attachment_id'] = ( $instance['attachment_id'] > 0 ) ? $instance['attachment_id'] : $instance['image'];
107
- $instance['attachment_id'] = apply_filters( 'image_widget_image_attachment_id', abs( $instance['attachment_id'] ), $args, $instance );
108
- $instance['size'] = apply_filters( 'image_widget_image_size', esc_attr( $instance['size'] ), $args, $instance );
109
- }
110
- $instance['imageurl'] = apply_filters( 'image_widget_image_url', esc_url( $instance['imageurl'] ), $args, $instance );
111
-
112
- // No longer using extracted vars. This is here for backwards compatibility.
113
- extract( $instance );
114
-
115
- include( $this->getTemplateHierarchy( 'widget' ) );
116
- }
117
- }
118
-
119
- /**
120
- * Update widget options
121
- *
122
- * @param object $new_instance Widget Instance
123
- * @param object $old_instance Widget Instance
124
- * @return object
125
- * @author Modern Tribe, Inc.
126
- */
127
- public function update( $new_instance, $old_instance ) {
128
- $instance = $old_instance;
129
- $new_instance = wp_parse_args( (array) $new_instance, self::get_defaults() );
130
- $instance['title'] = strip_tags($new_instance['title']);
131
- if ( current_user_can('unfiltered_html') ) {
132
- $instance['description'] = $new_instance['description'];
133
- } else {
134
- $instance['description'] = wp_filter_post_kses($new_instance['description']);
135
- }
136
- $instance['link'] = $new_instance['link'];
137
- $instance['linkid'] = $new_instance['linkid'];
138
- $instance['linktarget'] = $new_instance['linktarget'];
139
- $instance['width'] = abs( $new_instance['width'] );
140
- $instance['height'] =abs( $new_instance['height'] );
141
- if ( !defined( 'IMAGE_WIDGET_COMPATIBILITY_TEST' ) ) {
142
- $instance['size'] = $new_instance['size'];
143
- }
144
- $instance['align'] = $new_instance['align'];
145
- $instance['alt'] = $new_instance['alt'];
146
- $instance['rel'] = $new_instance['rel'];
147
-
148
- // Reverse compatibility with $image, now called $attachement_id
149
- if ( !defined( 'IMAGE_WIDGET_COMPATIBILITY_TEST' ) && $new_instance['attachment_id'] > 0 ) {
150
- $instance['attachment_id'] = abs( $new_instance['attachment_id'] );
151
- } elseif ( $new_instance['image'] > 0 ) {
152
- $instance['attachment_id'] = $instance['image'] = abs( $new_instance['image'] );
153
- if ( class_exists('ImageWidgetDeprecated') ) {
154
- $instance['imageurl'] = ImageWidgetDeprecated::get_image_url( $instance['image'], $instance['width'], $instance['height'] ); // image resizing not working right now
155
- }
156
- }
157
- $instance['imageurl'] = $new_instance['imageurl']; // deprecated
158
-
159
- $instance['aspect_ratio'] = $this->get_image_aspect_ratio( $instance );
160
-
161
- return $instance;
162
- }
163
-
164
- /**
165
- * Form UI
166
- *
167
- * @param object $instance Widget Instance
168
- * @author Modern Tribe, Inc.
169
- */
170
- public function form( $instance ) {
171
- $instance = wp_parse_args( (array) $instance, self::get_defaults() );
172
- if ( $this->use_old_uploader() ) {
173
- include( $this->getTemplateHierarchy( 'widget-admin.deprecated' ) );
174
- } else {
175
- include( $this->getTemplateHierarchy( 'widget-admin' ) );
176
- }
177
- }
178
-
179
- /**
180
- * Admin header css
181
- *
182
- * @author Modern Tribe, Inc.
183
- */
184
- public function admin_head() {
185
- ?>
186
- <style type="text/css">
187
- .uploader input.button {
188
- width: 100%;
189
- height: 34px;
190
- line-height: 33px;
191
- margin-top: 15px;
192
- }
193
- .tribe_preview .aligncenter {
194
- display: block;
195
- margin-left: auto !important;
196
- margin-right: auto !important;
197
- }
198
- .tribe_preview {
199
- overflow: hidden;
200
- max-height: 300px;
201
- }
202
- .tribe_preview img {
203
- margin: 10px 0;
204
- height: auto;
205
- }
206
- </style>
207
- <?php
208
- }
209
-
210
- /**
211
- * Render an array of default values.
212
- *
213
- * @return array default values
214
- */
215
- private static function get_defaults() {
216
-
217
- $defaults = array(
218
- 'title' => '',
219
- 'description' => '',
220
- 'link' => '',
221
- 'linkid' => '',
222
- 'linktarget' => '',
223
- 'width' => 0,
224
- 'height' => 0,
225
- 'maxwidth' => '100%',
226
- 'maxheight' => '',
227
- 'image' => 0, // reverse compatible - now attachement_id
228
- 'imageurl' => '', // reverse compatible.
229
- 'align' => 'none',
230
- 'alt' => '',
231
- 'rel' => '',
232
- );
233
-
234
- if ( !defined( 'IMAGE_WIDGET_COMPATIBILITY_TEST' ) ) {
235
- $defaults['size'] = self::CUSTOM_IMAGE_SIZE_SLUG;
236
- $defaults['attachment_id'] = 0;
237
- }
238
-
239
- return $defaults;
240
- }
241
-
242
- /**
243
- * Render the image html output.
244
- *
245
- * @param array $instance
246
- * @param bool $include_link will only render the link if this is set to true. Otherwise link is ignored.
247
- * @return string image html
248
- */
249
- private function get_image_html( $instance, $include_link = true ) {
250
-
251
- // Backwards compatible image display.
252
- if ( $instance['attachment_id'] == 0 && $instance['image'] > 0 ) {
253
- $instance['attachment_id'] = $instance['image'];
254
- }
255
-
256
- $output = '';
257
-
258
- if ( $include_link && !empty( $instance['link'] ) ) {
259
- $attr = array(
260
- 'href' => $instance['link'],
261
- 'id' => $instance['linkid'],
262
- 'target' => $instance['linktarget'],
263
- 'class' => $this->widget_options['classname'].'-image-link',
264
- 'title' => ( !empty( $instance['alt'] ) ) ? $instance['alt'] : $instance['title'],
265
- 'rel' => $instance['rel'],
266
- );
267
- $attr = apply_filters('image_widget_link_attributes', $attr, $instance );
268
- $attr = array_map( 'esc_attr', $attr );
269
- $output = '<a';
270
- foreach ( $attr as $name => $value ) {
271
- $output .= sprintf( ' %s="%s"', $name, $value );
272
- }
273
- $output .= '>';
274
- }
275
-
276
- $size = $this->get_image_size( $instance );
277
- if ( is_array( $size ) ) {
278
- $instance['width'] = $size[0];
279
- $instance['height'] = $size[1];
280
- } elseif ( !empty( $instance['attachment_id'] ) ) {
281
- //$instance['width'] = $instance['height'] = 0;
282
- $image_details = wp_get_attachment_image_src( $instance['attachment_id'], $size );
283
- if ($image_details) {
284
- $instance['imageurl'] = $image_details[0];
285
- $instance['width'] = $image_details[1];
286
- $instance['height'] = $image_details[2];
287
- }
288
- }
289
- $instance['width'] = abs( $instance['width'] );
290
- $instance['height'] = abs( $instance['height'] );
291
-
292
- $attr = array();
293
- $attr['alt'] = ( !empty( $instance['alt'] ) ) ? $instance['alt'] : $instance['title'];
294
- if (is_array($size)) {
295
- $attr['class'] = 'attachment-'.join('x',$size);
296
- } else {
297
- $attr['class'] = 'attachment-'.$size;
298
- }
299
- $attr['style'] = '';
300
- if (!empty($instance['maxwidth'])) {
301
- $attr['style'] .= "max-width: {$instance['maxwidth']};";
302
- }
303
- if (!empty($instance['maxheight'])) {
304
- $attr['style'] .= "max-height: {$instance['maxheight']};";
305
- }
306
- if (!empty($instance['align']) && $instance['align'] != 'none') {
307
- $attr['class'] .= " align{$instance['align']}";
308
- }
309
- $attr = apply_filters( 'image_widget_image_attributes', $attr, $instance );
310
-
311
- // If there is an imageurl, use it to render the image. Eventually we should kill this and simply rely on attachment_ids.
312
- if ( !empty( $instance['imageurl'] ) ) {
313
- // If all we have is an image src url we can still render an image.
314
- $attr['src'] = $instance['imageurl'];
315
- $attr = array_map( 'esc_attr', $attr );
316
- $hwstring = image_hwstring( $instance['width'], $instance['height'] );
317
- $output .= rtrim("<img $hwstring");
318
- foreach ( $attr as $name => $value ) {
319
- $output .= sprintf( ' %s="%s"', $name, $value );
320
- }
321
- $output .= ' />';
322
- } elseif( abs( $instance['attachment_id'] ) > 0 ) {
323
- $output .= wp_get_attachment_image($instance['attachment_id'], $size, false, $attr);
324
- }
325
-
326
- if ( $include_link && !empty( $instance['link'] ) ) {
327
- $output .= '</a>';
328
- }
329
-
330
- return $output;
331
- }
332
-
333
- /**
334
- * Get all possible image sizes to choose from
335
- *
336
- * @return array
337
- */
338
- private function possible_image_sizes() {
339
- $registered = get_intermediate_image_sizes();
340
- // label other sizes with their image size "ID"
341
- $registered = array_combine( $registered, $registered );
342
-
343
- $possible_sizes = array_merge( $registered, array(
344
- 'full' => __('Full Size', 'image_widget'),
345
- 'thumbnail' => __('Thumbnail', 'image_widget'),
346
- 'medium' => __('Medium', 'image_widget'),
347
- 'large' => __('Large', 'image_widget'),
348
- self::CUSTOM_IMAGE_SIZE_SLUG => __('Custom', 'image_widget'),
349
- ) );
350
-
351
- return (array) apply_filters( 'image_size_names_choose', $possible_sizes );
352
- }
353
-
354
- /**
355
- * Assesses the image size in case it has not been set or in case there is a mismatch.
356
- *
357
- * @param $instance
358
- * @return array|string
359
- */
360
- private function get_image_size( $instance ) {
361
- if ( !empty( $instance['size'] ) && $instance['size'] != self::CUSTOM_IMAGE_SIZE_SLUG ) {
362
- $size = $instance['size'];
363
- } elseif ( isset( $instance['width'] ) && is_numeric($instance['width']) && isset( $instance['height'] ) && is_numeric($instance['height']) ) {
364
- //$size = array(abs($instance['width']),abs($instance['height']));
365
- $size = array($instance['width'],$instance['height']);
366
- } else {
367
- $size = 'full';
368
- }
369
- return $size;
370
- }
371
-
372
- /**
373
- * Establish the aspect ratio of the image.
374
- *
375
- * @param $instance
376
- * @return float|number
377
- */
378
- private function get_image_aspect_ratio( $instance ) {
379
- if ( !empty( $instance['aspect_ratio'] ) ) {
380
- return abs( $instance['aspect_ratio'] );
381
- } else {
382
- $attachment_id = ( !empty($instance['attachment_id']) ) ? $instance['attachment_id'] : $instance['image'];
383
- if ( !empty($attachment_id) ) {
384
- $image_details = wp_get_attachment_image_src( $attachment_id, 'full' );
385
- if ($image_details) {
386
- return ( $image_details[1]/$image_details[2] );
387
- }
388
- }
389
- }
390
- }
391
-
392
- /**
393
- * Loads theme files in appropriate hierarchy: 1) child theme,
394
- * 2) parent template, 3) plugin resources. will look in the image-widget/
395
- * directory in a theme and the views/ directory in the plugin
396
- *
397
- * @param string $template template file to search for
398
- * @return template path
399
- * @author Modern Tribe, Inc. (Matt Wiebe)
400
- **/
401
-
402
- public function getTemplateHierarchy($template) {
403
- // whether or not .php was added
404
- $template_slug = rtrim($template, '.php');
405
- $template = $template_slug . '.php';
406
-
407
- if ( $theme_file = locate_template(array('image-widget/'.$template)) ) {
408
- $file = $theme_file;
409
- } else {
410
- $file = 'views/' . $template;
411
- }
412
- return apply_filters( 'sp_template_image-widget_'.$template, $file);
413
- }
414
-
415
-
416
- /**
417
- * Display a thank you nag when the plugin has been upgraded.
418
- */
419
- public function post_upgrade_nag() {
420
- if ( !current_user_can('install_plugins') ) return;
421
-
422
- $version_key = '_image_widget_version';
423
- if ( get_site_option( $version_key ) == self::VERSION ) return;
424
-
425
- $msg = sprintf(__('Thanks for upgrading the Image Widget! If you like this plugin, please consider <a href="%s" target="_blank">rating it</a> and maybe even check out our premium plugins including our <a href="%s" target="_blank">Events Calendar Pro</a>!', 'image-widget'),'http://wordpress.org/extend/plugins/image-widget/?source=image-widget&pos=nag','http://tri.be/wordpress-events-calendar-pro/?source=image-widget&pos=nag');
426
- echo "<div class='update-nag'>$msg</div>";
427
-
428
- update_site_option( $version_key, self::VERSION );
429
- }
430
-
431
- /**
432
- * Display an informational section in the plugin admin ui.
433
- * @param $meta
434
- * @param $file
435
- *
436
- * @return array
437
- */
438
- public function plugin_row_meta( $meta, $file ) {
439
- if ( $file == plugin_basename( dirname(__FILE__).'/image-widget.php' ) ) {
440
- $meta[] = '<span class="tribe-test">'.sprintf(__('Check out our other <a href="%s" target="_blank">plugins</a> including our <a href="%s" target="_blank">Events Calendar Pro</a>!', 'image-widget'),'http://tri.be/products/?source=image-widget&pos=pluginlist','http://tri.be/wordpress-events-calendar-pro/?source=image-widget&pos=pluginlist').'</span>';
441
- }
442
- return $meta;
443
- }
444
- }
 
1
+ <?php
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
8
+ Author URI: http://m.tri.be/26
9
+ Text Domain: image-widget
10
+ Domain Path: /lang
11
+ */
12
+
13
+ // Block direct requests
14
+ if ( ! defined( 'ABSPATH' ) ) {
15
+ die( '-1' );
16
+ }
17
+
18
+ // Load the widget on widgets_init
19
+ function tribe_load_image_widget() {
20
+ register_widget( 'Tribe_Image_Widget' );
21
+ }
22
+ add_action( 'widgets_init', 'tribe_load_image_widget' );
23
+
24
+ /**
25
+ * Tribe_Image_Widget class
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
+ *
36
+ * @author Modern Tribe, Inc.
37
+ */
38
+ public function __construct() {
39
+ load_plugin_textdomain( 'image-widget', false, trailingslashit( basename( dirname( __FILE__ ) ) ) . 'lang/' );
40
+ $widget_ops = array( 'classname' => 'widget_sp_image', 'description' => __( 'Showcase a single image with a Title, URL, and a Description', 'image-widget' ) );
41
+ $control_ops = array( 'id_base' => 'widget_sp_image' );
42
+ parent::__construct( 'widget_sp_image', __( 'Image Widget', 'image-widget' ), $widget_ops, $control_ops );
43
+
44
+ if ( $this->use_old_uploader() ) {
45
+ require_once( 'lib/ImageWidgetDeprecated.php' );
46
+ new ImageWidgetDeprecated( $this );
47
+ } else {
48
+ add_action( 'sidebar_admin_setup', array( $this, 'admin_setup' ) );
49
+ }
50
+ add_action( 'admin_head-widgets.php', array( $this, 'admin_head' ) );
51
+
52
+ add_action( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
53
+
54
+ if ( ! defined( 'I_HAVE_SUPPORTED_THE_IMAGE_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
+ /**
61
+ * Test to see if this version of WordPress supports the new image manager.
62
+ * @return bool true if the current version of WordPress does NOT support the current image management tech.
63
+ */
64
+ private function use_old_uploader() {
65
+ if ( defined( 'IMAGE_WIDGET_COMPATIBILITY_TEST' ) ) return true;
66
+ return ! function_exists( 'wp_enqueue_media' );
67
+ }
68
+
69
+ /**
70
+ * Enqueue all the javascript.
71
+ */
72
+ public function admin_setup() {
73
+ wp_enqueue_media();
74
+ wp_enqueue_script( 'tribe-image-widget', plugins_url( 'resources/js/image-widget.js', __FILE__ ), array( 'jquery', 'media-upload', 'media-views' ), self::VERSION );
75
+
76
+ wp_localize_script( 'tribe-image-widget', 'TribeImageWidget', array(
77
+ 'frame_title' => __( 'Select an Image', 'image-widget' ),
78
+ 'button_title' => __( 'Insert Into Widget', 'image-widget' ),
79
+ ) );
80
+ }
81
+
82
+ /**
83
+ * Widget frontend output
84
+ *
85
+ * @param array $args
86
+ * @param array $instance
87
+ * @author Modern Tribe, Inc.
88
+ */
89
+ public function widget( $args, $instance ) {
90
+ extract( $args );
91
+ $instance = wp_parse_args( (array) $instance, self::get_defaults() );
92
+ if ( ! empty( $instance['imageurl'] ) || ! empty( $instance['attachment_id'] ) ) {
93
+
94
+ $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'] );
95
+ $instance['description'] = apply_filters( 'widget_text', $instance['description'], $args, $instance );
96
+ $instance['link'] = apply_filters( 'image_widget_image_link', esc_url( $instance['link'] ), $args, $instance );
97
+ $instance['linkid'] = apply_filters( 'image_widget_image_link_id', esc_attr( $instance['linkid'] ), $args, $instance );
98
+ $instance['linktarget'] = apply_filters( 'image_widget_image_link_target', esc_attr( $instance['linktarget'] ), $args, $instance );
99
+ $instance['width'] = apply_filters( 'image_widget_image_width', abs( $instance['width'] ), $args, $instance );
100
+ $instance['height'] = apply_filters( 'image_widget_image_height', abs( $instance['height'] ), $args, $instance );
101
+ $instance['maxwidth'] = apply_filters( 'image_widget_image_maxwidth', esc_attr( $instance['maxwidth'] ), $args, $instance );
102
+ $instance['maxheight'] = apply_filters( 'image_widget_image_maxheight', esc_attr( $instance['maxheight'] ), $args, $instance );
103
+ $instance['align'] = apply_filters( 'image_widget_image_align', esc_attr( $instance['align'] ), $args, $instance );
104
+ $instance['alt'] = apply_filters( 'image_widget_image_alt', esc_attr( $instance['alt'] ), $args, $instance );
105
+ $instance['rel'] = apply_filters( 'image_widget_image_rel', esc_attr( $instance['rel'] ), $args, $instance );
106
+
107
+ if ( ! defined( 'IMAGE_WIDGET_COMPATIBILITY_TEST' ) ) {
108
+ $instance['attachment_id'] = ( $instance['attachment_id'] > 0 ) ? $instance['attachment_id'] : $instance['image'];
109
+ $instance['attachment_id'] = apply_filters( 'image_widget_image_attachment_id', abs( $instance['attachment_id'] ), $args, $instance );
110
+ $instance['size'] = apply_filters( 'image_widget_image_size', esc_attr( $instance['size'] ), $args, $instance );
111
+ }
112
+ $instance['imageurl'] = apply_filters( 'image_widget_image_url', esc_url( $instance['imageurl'] ), $args, $instance );
113
+
114
+ // No longer using extracted vars. This is here for backwards compatibility.
115
+ extract( $instance );
116
+
117
+ include( $this->getTemplateHierarchy( 'widget' ) );
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Update widget options
123
+ *
124
+ * @param object $new_instance Widget Instance
125
+ * @param object $old_instance Widget Instance
126
+ * @return object
127
+ * @author Modern Tribe, Inc.
128
+ */
129
+ public function update( $new_instance, $old_instance ) {
130
+ $instance = $old_instance;
131
+ $new_instance = wp_parse_args( (array) $new_instance, self::get_defaults() );
132
+ $instance['title'] = strip_tags( $new_instance['title'] );
133
+ if ( current_user_can( 'unfiltered_html' ) ) {
134
+ $instance['description'] = $new_instance['description'];
135
+ } else {
136
+ $instance['description'] = wp_filter_post_kses( $new_instance['description'] );
137
+ }
138
+ $instance['link'] = $new_instance['link'];
139
+ $instance['linkid'] = $new_instance['linkid'];
140
+ $instance['linktarget'] = $new_instance['linktarget'];
141
+ $instance['width'] = abs( $new_instance['width'] );
142
+ $instance['height'] = abs( $new_instance['height'] );
143
+ if ( ! defined( 'IMAGE_WIDGET_COMPATIBILITY_TEST' ) ) {
144
+ $instance['size'] = $new_instance['size'];
145
+ }
146
+ $instance['align'] = $new_instance['align'];
147
+ $instance['alt'] = $new_instance['alt'];
148
+ $instance['rel'] = $new_instance['rel'];
149
+
150
+ // Reverse compatibility with $image, now called $attachement_id
151
+ if ( ! defined( 'IMAGE_WIDGET_COMPATIBILITY_TEST' ) && $new_instance['attachment_id'] > 0 ) {
152
+ $instance['attachment_id'] = abs( $new_instance['attachment_id'] );
153
+ } elseif ( $new_instance['image'] > 0 ) {
154
+ $instance['attachment_id'] = $instance['image'] = abs( $new_instance['image'] );
155
+ if ( class_exists( 'ImageWidgetDeprecated' ) ) {
156
+ $instance['imageurl'] = ImageWidgetDeprecated::get_image_url( $instance['image'], $instance['width'], $instance['height'] ); // image resizing not working right now
157
+ }
158
+ }
159
+ $instance['imageurl'] = $new_instance['imageurl']; // deprecated
160
+
161
+ $instance['aspect_ratio'] = $this->get_image_aspect_ratio( $instance );
162
+
163
+ return $instance;
164
+ }
165
+
166
+ /**
167
+ * Form UI
168
+ *
169
+ * @param object $instance Widget Instance
170
+ * @author Modern Tribe, Inc.
171
+ */
172
+ public function form( $instance ) {
173
+ $instance = wp_parse_args( (array) $instance, self::get_defaults() );
174
+ if ( $this->use_old_uploader() ) {
175
+ include( $this->getTemplateHierarchy( 'widget-admin.deprecated' ) );
176
+ } else {
177
+ include( $this->getTemplateHierarchy( 'widget-admin' ) );
178
+ }
179
+ }
180
+
181
+ /**
182
+ * Admin header css
183
+ *
184
+ * @author Modern Tribe, Inc.
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
+ /**
213
+ * Render an array of default values.
214
+ *
215
+ * @return array default values
216
+ */
217
+ private static function get_defaults() {
218
+
219
+ $defaults = array(
220
+ 'title' => '',
221
+ 'description' => '',
222
+ 'link' => '',
223
+ 'linkid' => '',
224
+ 'linktarget' => '',
225
+ 'width' => 0,
226
+ 'height' => 0,
227
+ 'maxwidth' => '100%',
228
+ 'maxheight' => '',
229
+ 'image' => 0, // reverse compatible - now attachement_id
230
+ 'imageurl' => '', // reverse compatible.
231
+ 'align' => 'none',
232
+ 'alt' => '',
233
+ 'rel' => '',
234
+ );
235
+
236
+ if ( ! defined( 'IMAGE_WIDGET_COMPATIBILITY_TEST' ) ) {
237
+ $defaults['size'] = self::CUSTOM_IMAGE_SIZE_SLUG;
238
+ $defaults['attachment_id'] = 0;
239
+ }
240
+
241
+ return $defaults;
242
+ }
243
+
244
+ /**
245
+ * Render the image html output.
246
+ *
247
+ * @param array $instance
248
+ * @param bool $include_link will only render the link if this is set to true. Otherwise link is ignored.
249
+ * @return string image html
250
+ */
251
+ private function get_image_html( $instance, $include_link = true ) {
252
+
253
+ // Backwards compatible image display.
254
+ if ( $instance['attachment_id'] == 0 && $instance['image'] > 0 ) {
255
+ $instance['attachment_id'] = $instance['image'];
256
+ }
257
+
258
+ $output = '';
259
+
260
+ if ( $include_link && ! empty( $instance['link'] ) ) {
261
+ $attr = array(
262
+ 'href' => $instance['link'],
263
+ 'id' => $instance['linkid'],
264
+ 'target' => $instance['linktarget'],
265
+ 'class' => $this->widget_options['classname'] . '-image-link',
266
+ 'title' => ( ! empty( $instance['alt'] ) ) ? $instance['alt'] : $instance['title'],
267
+ 'rel' => $instance['rel'],
268
+ );
269
+ $attr = apply_filters( 'image_widget_link_attributes', $attr, $instance );
270
+ $attr = array_map( 'esc_attr', $attr );
271
+ $output = '<a';
272
+ foreach ( $attr as $name => $value ) {
273
+ $output .= sprintf( ' %s="%s"', $name, $value );
274
+ }
275
+ $output .= '>';
276
+ }
277
+
278
+ $size = $this->get_image_size( $instance );
279
+ if ( is_array( $size ) ) {
280
+ $instance['width'] = $size[0];
281
+ $instance['height'] = $size[1];
282
+ } elseif ( ! empty( $instance['attachment_id'] ) ) {
283
+ //$instance['width'] = $instance['height'] = 0;
284
+ $image_details = wp_get_attachment_image_src( $instance['attachment_id'], $size );
285
+ if ( $image_details ) {
286
+ $instance['imageurl'] = $image_details[0];
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'] );
293
+
294
+ $attr = array();
295
+ $attr['alt'] = ( ! empty( $instance['alt'] ) ) ? $instance['alt'] : $instance['title'];
296
+ if ( is_array( $size ) ) {
297
+ $attr['class'] = 'attachment-' . join( 'x', $size );
298
+ } else {
299
+ $attr['class'] = 'attachment-' . $size;
300
+ }
301
+ $attr['style'] = '';
302
+ if ( ! empty( $instance['maxwidth'] ) ) {
303
+ $attr['style'] .= "max-width: {$instance['maxwidth']};";
304
+ }
305
+ if ( ! empty( $instance['maxheight'] ) ) {
306
+ $attr['style'] .= "max-height: {$instance['maxheight']};";
307
+ }
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.
314
+ if ( ! empty( $instance['imageurl'] ) ) {
315
+ // If all we have is an image src url we can still render an image.
316
+ $attr['src'] = $instance['imageurl'];
317
+ $attr = array_map( 'esc_attr', $attr );
318
+ $hwstring = image_hwstring( $instance['width'], $instance['height'] );
319
+ $output .= rtrim( "<img $hwstring" );
320
+ foreach ( $attr as $name => $value ) {
321
+ $output .= sprintf( ' %s="%s"', $name, $value );
322
+ }
323
+ $output .= ' />';
324
+ } elseif ( abs( $instance['attachment_id'] ) > 0 ) {
325
+ $output .= wp_get_attachment_image( $instance['attachment_id'], $size, false, $attr );
326
+ }
327
+
328
+ if ( $include_link && ! empty( $instance['link'] ) ) {
329
+ $output .= '</a>';
330
+ }
331
+
332
+ return $output;
333
+ }
334
+
335
+ /**
336
+ * Get all possible image sizes to choose from
337
+ *
338
+ * @return array
339
+ */
340
+ private function possible_image_sizes() {
341
+ $registered = get_intermediate_image_sizes();
342
+ // label other sizes with their image size "ID"
343
+ $registered = array_combine( $registered, $registered );
344
+
345
+ $possible_sizes = array_merge( $registered, array(
346
+ 'full' => __( 'Full Size', 'image-widget' ),
347
+ 'thumbnail' => __( 'Thumbnail', 'image-widget' ),
348
+ 'medium' => __( 'Medium', 'image-widget' ),
349
+ 'large' => __( 'Large', 'image-widget' ),
350
+ self::CUSTOM_IMAGE_SIZE_SLUG => __( 'Custom', 'image-widget' ),
351
+ ) );
352
+
353
+ return (array) apply_filters( 'image_size_names_choose', $possible_sizes );
354
+ }
355
+
356
+ /**
357
+ * Assesses the image size in case it has not been set or in case there is a mismatch.
358
+ *
359
+ * @param $instance
360
+ * @return array|string
361
+ */
362
+ private function get_image_size( $instance ) {
363
+ if ( ! empty( $instance['size'] ) && $instance['size'] != self::CUSTOM_IMAGE_SIZE_SLUG ) {
364
+ $size = $instance['size'];
365
+ } elseif ( isset( $instance['width'] ) && is_numeric( $instance['width'] ) && isset( $instance['height'] ) && is_numeric( $instance['height'] ) ) {
366
+ //$size = array(abs($instance['width']),abs($instance['height']));
367
+ $size = array( $instance['width'], $instance['height'] );
368
+ } else {
369
+ $size = 'full';
370
+ }
371
+ return $size;
372
+ }
373
+
374
+ /**
375
+ * Establish the aspect ratio of the image.
376
+ *
377
+ * @param $instance
378
+ * @return float|number
379
+ */
380
+ private function get_image_aspect_ratio( $instance ) {
381
+ if ( ! empty( $instance['aspect_ratio'] ) ) {
382
+ return abs( $instance['aspect_ratio'] );
383
+ } else {
384
+ $attachment_id = ( ! empty( $instance['attachment_id'] ) ) ? $instance['attachment_id'] : $instance['image'];
385
+ if ( ! empty( $attachment_id ) ) {
386
+ $image_details = wp_get_attachment_image_src( $attachment_id, 'full' );
387
+ if ( $image_details ) {
388
+ return ( $image_details[1] / $image_details[2] );
389
+ }
390
+ }
391
+ }
392
+ }
393
+
394
+ /**
395
+ * Loads theme files in appropriate hierarchy: 1) child theme,
396
+ * 2) parent template, 3) plugin resources. will look in the image-widget/
397
+ * directory in a theme and the views/ directory in the plugin
398
+ *
399
+ * @param string $template template file to search for
400
+ * @return template path
401
+ * @author Modern Tribe, Inc. (Matt Wiebe)
402
+ **/
403
+
404
+ public function getTemplateHierarchy( $template ) {
405
+ // whether or not .php was added
406
+ $template_slug = rtrim( $template, '.php' );
407
+ $template = $template_slug . '.php';
408
+
409
+ if ( $theme_file = locate_template( array( 'image-widget/' . $template ) ) ) {
410
+ $file = $theme_file;
411
+ } else {
412
+ $file = 'views/' . $template;
413
+ }
414
+ return apply_filters( 'sp_template_image-widget_' . $template, $file );
415
+ }
416
+
417
+ /**
418
+ * Display a thank you nag when the plugin has been upgraded.
419
+ */
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
+ $msg = sprintf( __( 'Thanks for using the Image Widget! If you like this plugin, please consider <a href="%s" target="_blank">rating it</a> and maybe even check out our premium plugins including our <a href="%s" target="_blank">Events Calendar Pro</a>!', 'image-widget' ), 'http://wordpress.org/plugins/image-widget/?source=image-widget&pos=nag', 'https://theeventscalendar.com/product/wordpress-events-calendar-pro/?source=image-widget&pos=nag' );
427
+ echo "<div class='update-nag'>$msg</div>";
428
+
429
+ update_site_option( $version_key, self::VERSION );
430
+ }
431
+
432
+ /**
433
+ * Display an informational section in the plugin admin ui.
434
+ * @param $meta
435
+ * @param $file
436
+ *
437
+ * @return array
438
+ */
439
+ public function plugin_row_meta( $meta, $file ) {
440
+ if ( $file == plugin_basename( dirname( __FILE__ ) . '/image-widget.php' ) ) {
441
+ $meta[] = '<span class="tribe-test">' . sprintf( __( 'Check out our other <a href="%s" target="_blank">plugins</a> including our <a href="%s" target="_blank">Events Calendar Pro</a>!', 'image-widget' ), 'https://theeventscalendar.com/products/?source=image-widget&pos=pluginlist', 'https://theeventscalendar.com/product/wordpress-events-calendar-pro/?source=image-widget&pos=pluginlist' ) . '</span>';
442
+ }
443
+ return $meta;
444
+ }
445
+ }
lang/image-widget.pot ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #, fuzzy
2
+ msgid ""
3
+ msgstr ""
4
+ "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
+ "Project-Id-Version: Image Widget\n"
6
+ "POT-Creation-Date: 2017-02-09 22:07-0500\n"
7
+ "PO-Revision-Date: 2017-02-09 22:06-0500\n"
8
+ "Last-Translator: \n"
9
+ "Language-Team: \n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Generator: Poedit 1.8.11\n"
14
+ "X-Poedit-Basepath: ..\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;_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:426
61
+ #, php-format
62
+ msgid ""
63
+ "Thanks for upgrading the Image Widget! If you like this plugin, please "
64
+ "consider <a href=\"%s\" target=\"_blank\">rating it</a> and maybe even check "
65
+ "out our premium plugins including our <a href=\"%s\" target=\"_blank"
66
+ "\">Events Calendar Pro</a>!"
67
+ msgstr ""
68
+
69
+ #: image-widget.php:441
70
+ #, php-format
71
+ msgid ""
72
+ "Check out our other <a href=\"%s\" target=\"_blank\">plugins</a> including "
73
+ "our <a href=\"%s\" target=\"_blank\">Events Calendar Pro</a>!"
74
+ msgstr ""
75
+
76
+ #: views/widget-admin.deprecated.php:10 views/widget-admin.php:23
77
+ msgid "Title"
78
+ msgstr ""
79
+
80
+ #: views/widget-admin.deprecated.php:13
81
+ msgid "Image"
82
+ msgstr ""
83
+
84
+ #: views/widget-admin.deprecated.php:17
85
+ msgid "Change Image"
86
+ msgstr ""
87
+
88
+ #: views/widget-admin.deprecated.php:17
89
+ msgid "Add Image"
90
+ msgstr ""
91
+
92
+ #: views/widget-admin.deprecated.php:25 views/widget-admin.php:33
93
+ msgid "Caption"
94
+ msgstr ""
95
+
96
+ #: views/widget-admin.deprecated.php:28 views/widget-admin.php:36
97
+ msgid "Link"
98
+ msgstr ""
99
+
100
+ #: views/widget-admin.deprecated.php:31 views/widget-admin.php:41
101
+ msgid "Stay in Window"
102
+ msgstr ""
103
+
104
+ #: views/widget-admin.deprecated.php:32 views/widget-admin.php:42
105
+ msgid "Open New Window"
106
+ msgstr ""
107
+
108
+ #: views/widget-admin.deprecated.php:35 views/widget-admin.php:61
109
+ msgid "Width"
110
+ msgstr ""
111
+
112
+ #: views/widget-admin.deprecated.php:38 views/widget-admin.php:64
113
+ msgid "Height"
114
+ msgstr ""
115
+
116
+ #: views/widget-admin.deprecated.php:41 views/widget-admin.php:69
117
+ msgid "Align"
118
+ msgstr ""
119
+
120
+ #: views/widget-admin.deprecated.php:43 views/widget-admin.php:71
121
+ msgid "none"
122
+ msgstr ""
123
+
124
+ #: views/widget-admin.deprecated.php:44 views/widget-admin.php:72
125
+ msgid "left"
126
+ msgstr ""
127
+
128
+ #: views/widget-admin.deprecated.php:45 views/widget-admin.php:73
129
+ msgid "center"
130
+ msgstr ""
131
+
132
+ #: views/widget-admin.deprecated.php:46 views/widget-admin.php:74
133
+ msgid "right"
134
+ msgstr ""
135
+
136
+ #: views/widget-admin.deprecated.php:49 views/widget-admin.php:26
137
+ msgid "Alternate Text"
138
+ msgstr ""
139
+
140
+ #: views/widget-admin.php:29
141
+ msgid "Related"
142
+ msgstr ""
143
+
144
+ #: views/widget-admin.php:31
145
+ msgid ""
146
+ "A recommended HTML5 related terms list is available <a href=\"http://"
147
+ "microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions\" "
148
+ "target=\"_blank\">here</a>."
149
+ msgstr ""
150
+
151
+ #: views/widget-admin.php:38
152
+ msgid "Link ID"
153
+ msgstr ""
154
+
155
+ #: views/widget-admin.php:49
156
+ msgid "Size"
157
+ msgstr ""
158
+
159
+ #. Plugin URI of the plugin/theme
160
+ msgid "http://wordpress.org/plugins/image-widget/"
161
+ msgstr ""
162
+
163
+ #. Description of the plugin/theme
164
+ msgid ""
165
+ "A simple image widget that uses the native WordPress media manager to add "
166
+ "image widgets to your site."
167
+ msgstr ""
168
+
169
+ #. Author of the plugin/theme
170
+ msgid "Modern Tribe, Inc."
171
+ msgstr ""
172
+
173
+ #. Author URI of the plugin/theme
174
+ msgid "http://m.tri.be/26"
175
+ msgstr ""
lib/ImageWidgetDeprecated.php CHANGED
@@ -63,7 +63,7 @@ class ImageWidgetDeprecated {
63
  function replace_text_in_thickbox($translated_text, $source_text, $domain) {
64
  if ( $this->is_sp_widget_context() ) {
65
  if ('Insert into Post' == $source_text) {
66
- return __('Insert Into Widget', 'image_widget' );
67
  }
68
  }
69
  return $translated_text;
63
  function replace_text_in_thickbox($translated_text, $source_text, $domain) {
64
  if ( $this->is_sp_widget_context() ) {
65
  if ('Insert into Post' == $source_text) {
66
+ return __('Insert Into Widget', 'image-widget' );
67
  }
68
  }
69
  return $translated_text;
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
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.2.2
8
 
9
  == Description ==
10
 
@@ -19,15 +19,13 @@ A simple image widget that uses the native WordPress media manager to add image
19
  * Supports override of template so that you can override the template for your theme!
20
  * Responsive
21
 
22
- This plugin is actively supported and we will do our best to help you. In return we simply as 3 things:
23
 
24
  1. Help Out. If you see a question on the forum you can help with or have a great idea and want to code it up and submit a patch, that would be just plain awesome and we will shower your with praise. Might even be a good way to get to know us and lead to some paid work if you freelance. Also, we are happy to post translations if you provide them.
25
  1. [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4BSPTNFFY6AL6) - if this is generating enough revenue to support our time it makes all the difference in the world.
26
- 1. Support us by buying our Premium plugins. In particular, check out [Events Calendar Pro](https://theeventscalendar.com/product/wordpress-events-calendar-pro/?src=imagewidget) and [Event Tickets Plus](https://theeventscalendar.com/product/wordpress-event-tickets-plus/?src=imagewidget).
27
 
28
- Note, we're also on github in case you want to add some pull requests or a fork!
29
-
30
- https://github.com/moderntribe/image-widget
31
 
32
  == Installation ==
33
 
@@ -38,15 +36,25 @@ https://github.com/moderntribe/image-widget
38
  in your Manage menu.
39
  1. Go to the Appearance > Widget page and place the widget in your sidebar in the Design
40
 
41
- If you find any bugs or have any ideas, please mail us.
42
-
43
- Please visit the forum for questions or comments: http://wordpress.org/tags/image-widget/
44
 
45
  = Requirements =
46
 
47
- * PHP 5.1 or above
48
  * WordPress 3.5 or above
49
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  == Documentation ==
51
 
52
  The built in template can be overridden by files within your template.
@@ -155,6 +163,13 @@ For more info on the philosophy here, check out our [blog post](http://tri.be/de
155
 
156
  == Changelog ==
157
 
 
 
 
 
 
 
 
158
  = 4.2.2 =
159
 
160
  * Feature - Include registered image sizes in the list of selectable items (props to aaemnnosttv for the pull request!)
@@ -447,14 +462,3 @@ Also, several languages will no longer be supported until new translations are s
447
 
448
  http://wordpress.org/support/topic/image-widget-40-translations-needed-2
449
 
450
- == Screenshots ==
451
-
452
- 1. Image Widget admin screen.
453
- 1. Media manager integration.
454
- 1. Image Widget on the front of a plain Wordpress install.
455
-
456
- == Frequently Asked Questions ==
457
-
458
- = Where do I go to file a bug or ask a question? =
459
-
460
- Please visit the forum for questions or comments: http://wordpress.org/tags/image-widget/
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
8
 
9
  == Description ==
10
 
19
  * Supports override of template so that you can override the template for your theme!
20
  * Responsive
21
 
22
+ This plugin is actively supported and we will do our best to help you. In return we simply ask 3 things:
23
 
24
  1. Help Out. If you see a question on the forum you can help with or have a great idea and want to code it up and submit a patch, that would be just plain awesome and we will shower your with praise. Might even be a good way to get to know us and lead to some paid work if you freelance. Also, we are happy to post translations if you provide them.
25
  1. [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4BSPTNFFY6AL6) - if this is generating enough revenue to support our time it makes all the difference in the world.
26
+ 1. Support us by buying our Premium plugins. In particular, *check out [Events Calendar Pro](https://theeventscalendar.com/product/wordpress-events-calendar-pro/?src=imagewidget) and [Event Tickets Plus](https://theeventscalendar.com/product/wordpress-event-tickets-plus/?src=imagewidget)*.
27
 
28
+ [Check us out on GitHub](https://github.com/moderntribe/image-widget) in case you want to add some pull requests or a fork!
 
 
29
 
30
  == Installation ==
31
 
36
  in your Manage menu.
37
  1. Go to the Appearance > Widget page and place the widget in your sidebar in the Design
38
 
39
+ If you find any bugs or have any ideas, please [visit the forum for questions or comments](http://wordpress.org/support/plugin/image-widget/)
 
 
40
 
41
  = Requirements =
42
 
43
+ * PHP 5.2 or above
44
  * WordPress 3.5 or above
45
 
46
+ == Screenshots ==
47
+
48
+ 1. Image Widget admin screen.
49
+ 1. Media manager integration.
50
+ 1. Image Widget on the front of a plain WordPress install.
51
+
52
+ == Frequently Asked Questions ==
53
+
54
+ = Where do I go to file a bug or ask a question? =
55
+
56
+ Please [visit the forum for questions or comments](http://wordpress.org/support/plugin/image-widget/)
57
+
58
  == Documentation ==
59
 
60
  The built in template can be overridden by files within your template.
163
 
164
  == Changelog ==
165
 
166
+ = 4.3 =
167
+
168
+ * Translations - fixed compatibility with translate.wordpress.org
169
+ * Translations - restored the pot file for easier community translations
170
+ * Tweak - fixed a typo
171
+ * Tweak - Minor code cleanup
172
+
173
  = 4.2.2 =
174
 
175
  * Feature - Include registered image sizes in the list of selectable items (props to aaemnnosttv for the pull request!)
462
 
463
  http://wordpress.org/support/topic/image-widget-40-translations-needed-2
464
 
 
 
 
 
 
 
 
 
 
 
 
screenshot-1.png DELETED
Binary file
screenshot-2.png DELETED
Binary file
screenshot-3.png DELETED
Binary file
views/widget-admin.deprecated.php CHANGED
@@ -7,14 +7,14 @@
7
  if ( !defined('ABSPATH') )
8
  die('-1');
9
  ?>
10
- <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'image_widget'); ?>:</label>
11
  <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['title'])); ?>" /></p>
12
 
13
- <p><label for="<?php echo $this->get_field_id('image'); ?>"><?php _e('Image', 'image_widget'); ?>:</label>
14
  <?php
15
  $media_upload_iframe_src = "media-upload.php?type=image&post_id=0&widget_id=".$this->id; //NOTE #1: the widget id is added here to allow uploader to only return array if this is used with image widget so that all other uploads are not harmed.
16
  $image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src");
17
- $image_title = (!empty($instance['image'])) ? __('Change Image', 'image_widget') : __('Add Image', 'image_widget');
18
  ?><br />
19
  <a href="<?php echo $image_upload_iframe_src; ?>&TB_iframe=true" id="add_image-<?php echo $this->get_field_id('image'); ?>" class="thickbox-image-widget" title='<?php echo $image_title; ?>' onClick="imageWidget.setActiveWidget('<?php echo $this->id; ?>');return false;" style="text-decoration:none"><img src='images/media-button-image.gif' alt='<?php echo $image_title; ?>' align="absmiddle" /> <?php echo $image_title; ?></a>
20
  <div id="display-<?php echo $this->get_field_id('image'); ?>"><?php echo $this->get_image_html($instance); ?></div>
@@ -22,29 +22,29 @@ if ( !defined('ABSPATH') )
22
  <input id="<?php echo $this->get_field_id('image'); ?>" name="<?php echo $this->get_field_name('image'); ?>" type="hidden" value="<?php echo $instance['image']; ?>" />
23
  </p>
24
 
25
- <p><label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Caption', 'image_widget'); ?>:</label>
26
  <textarea rows="8" class="widefat" id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>"><?php echo format_to_edit($instance['description']); ?></textarea></p>
27
 
28
- <p><label for="<?php echo $this->get_field_id('link'); ?>"><?php _e('Link', 'image_widget'); ?>:</label>
29
  <input class="widefat" id="<?php echo $this->get_field_id('link'); ?>" name="<?php echo $this->get_field_name('link'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['link'])); ?>" /><br />
30
  <select name="<?php echo $this->get_field_name('linktarget'); ?>" id="<?php echo $this->get_field_id('linktarget'); ?>">
31
- <option value="_self"<?php selected( $instance['linktarget'], '_self' ); ?>><?php _e('Stay in Window', 'image_widget'); ?></option>
32
- <option value="_blank"<?php selected( $instance['linktarget'], '_blank' ); ?>><?php _e('Open New Window', 'image_widget'); ?></option>
33
  </select></p>
34
 
35
- <p><label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width', 'image_widget'); ?>:</label>
36
  <input id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['width'])); ?>" onchange="imageWidget.changeImgWidth('<?php echo $this->id; ?>')" /></p>
37
 
38
- <p><label for="<?php echo $this->get_field_id('height'); ?>"><?php _e('Height', 'image_widget'); ?>:</label>
39
  <input id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['height'])); ?>" onchange="imageWidget.changeImgHeight('<?php echo $this->id; ?>')" /></p>
40
 
41
- <p><label for="<?php echo $this->get_field_id('align'); ?>"><?php _e('Align', 'image_widget'); ?>:</label>
42
  <select name="<?php echo $this->get_field_name('align'); ?>" id="<?php echo $this->get_field_id('align'); ?>" onchange="imageWidget.changeImgAlign('<?php echo $this->id; ?>')">
43
- <option value="none"<?php selected( $instance['align'], 'none' ); ?>><?php _e('none', 'image_widget'); ?></option>
44
- <option value="left"<?php selected( $instance['align'], 'left' ); ?>><?php _e('left', 'image_widget'); ?></option>
45
- <option value="center"<?php selected( $instance['align'], 'center' ); ?>><?php _e('center', 'image_widget'); ?></option>
46
- <option value="right"<?php selected( $instance['align'], 'right' ); ?>><?php _e('right', 'image_widget'); ?></option>
47
  </select></p>
48
 
49
- <p><label for="<?php echo $this->get_field_id('alt'); ?>"><?php _e('Alternate Text', 'image_widget'); ?>:</label>
50
  <input id="<?php echo $this->get_field_id('alt'); ?>" name="<?php echo $this->get_field_name('alt'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['alt'])); ?>" /></p>
7
  if ( !defined('ABSPATH') )
8
  die('-1');
9
  ?>
10
+ <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'image-widget'); ?>:</label>
11
  <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['title'])); ?>" /></p>
12
 
13
+ <p><label for="<?php echo $this->get_field_id('image'); ?>"><?php _e('Image', 'image-widget'); ?>:</label>
14
  <?php
15
  $media_upload_iframe_src = "media-upload.php?type=image&post_id=0&widget_id=".$this->id; //NOTE #1: the widget id is added here to allow uploader to only return array if this is used with image widget so that all other uploads are not harmed.
16
  $image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src");
17
+ $image_title = (!empty($instance['image'])) ? __('Change Image', 'image-widget') : __('Add Image', 'image-widget');
18
  ?><br />
19
  <a href="<?php echo $image_upload_iframe_src; ?>&TB_iframe=true" id="add_image-<?php echo $this->get_field_id('image'); ?>" class="thickbox-image-widget" title='<?php echo $image_title; ?>' onClick="imageWidget.setActiveWidget('<?php echo $this->id; ?>');return false;" style="text-decoration:none"><img src='images/media-button-image.gif' alt='<?php echo $image_title; ?>' align="absmiddle" /> <?php echo $image_title; ?></a>
20
  <div id="display-<?php echo $this->get_field_id('image'); ?>"><?php echo $this->get_image_html($instance); ?></div>
22
  <input id="<?php echo $this->get_field_id('image'); ?>" name="<?php echo $this->get_field_name('image'); ?>" type="hidden" value="<?php echo $instance['image']; ?>" />
23
  </p>
24
 
25
+ <p><label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Caption', 'image-widget'); ?>:</label>
26
  <textarea rows="8" class="widefat" id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>"><?php echo format_to_edit($instance['description']); ?></textarea></p>
27
 
28
+ <p><label for="<?php echo $this->get_field_id('link'); ?>"><?php _e('Link', 'image-widget'); ?>:</label>
29
  <input class="widefat" id="<?php echo $this->get_field_id('link'); ?>" name="<?php echo $this->get_field_name('link'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['link'])); ?>" /><br />
30
  <select name="<?php echo $this->get_field_name('linktarget'); ?>" id="<?php echo $this->get_field_id('linktarget'); ?>">
31
+ <option value="_self"<?php selected( $instance['linktarget'], '_self' ); ?>><?php _e('Stay in Window', 'image-widget'); ?></option>
32
+ <option value="_blank"<?php selected( $instance['linktarget'], '_blank' ); ?>><?php _e('Open New Window', 'image-widget'); ?></option>
33
  </select></p>
34
 
35
+ <p><label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width', 'image-widget'); ?>:</label>
36
  <input id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['width'])); ?>" onchange="imageWidget.changeImgWidth('<?php echo $this->id; ?>')" /></p>
37
 
38
+ <p><label for="<?php echo $this->get_field_id('height'); ?>"><?php _e('Height', 'image-widget'); ?>:</label>
39
  <input id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['height'])); ?>" onchange="imageWidget.changeImgHeight('<?php echo $this->id; ?>')" /></p>
40
 
41
+ <p><label for="<?php echo $this->get_field_id('align'); ?>"><?php _e('Align', 'image-widget'); ?>:</label>
42
  <select name="<?php echo $this->get_field_name('align'); ?>" id="<?php echo $this->get_field_id('align'); ?>" onchange="imageWidget.changeImgAlign('<?php echo $this->id; ?>')">
43
+ <option value="none"<?php selected( $instance['align'], 'none' ); ?>><?php _e('none', 'image-widget'); ?></option>
44
+ <option value="left"<?php selected( $instance['align'], 'left' ); ?>><?php _e('left', 'image-widget'); ?></option>
45
+ <option value="center"<?php selected( $instance['align'], 'center' ); ?>><?php _e('center', 'image-widget'); ?></option>
46
+ <option value="right"<?php selected( $instance['align'], 'right' ); ?>><?php _e('right', 'image-widget'); ?></option>
47
  </select></p>
48
 
49
+ <p><label for="<?php echo $this->get_field_id('alt'); ?>"><?php _e('Alternate Text', 'image-widget'); ?>:</label>
50
  <input id="<?php echo $this->get_field_id('alt'); ?>" name="<?php echo $this->get_field_name('alt'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['alt'])); ?>" /></p>
views/widget-admin.php CHANGED
@@ -4,74 +4,73 @@
4
  */
5
 
6
  // Block direct requests
7
- if ( !defined('ABSPATH') )
8
- die('-1');
9
 
10
- $id_prefix = $this->get_field_id('');
11
  ?>
12
  <div class="uploader">
13
- <input type="submit" class="button" name="<?php echo $this->get_field_name('uploader_button'); ?>" id="<?php echo $this->get_field_id('uploader_button'); ?>" value="<?php _e('Select an Image', 'image_widget'); ?>" onclick="imageWidget.uploader( '<?php echo $this->id; ?>', '<?php echo $id_prefix; ?>' ); return false;" />
14
- <div class="tribe_preview" id="<?php echo $this->get_field_id('preview'); ?>">
15
- <?php echo $this->get_image_html($instance, false); ?>
16
  </div>
17
- <input type="hidden" id="<?php echo $this->get_field_id('attachment_id'); ?>" name="<?php echo $this->get_field_name('attachment_id'); ?>" value="<?php echo abs($instance['attachment_id']); ?>" />
18
- <input type="hidden" id="<?php echo $this->get_field_id('imageurl'); ?>" name="<?php echo $this->get_field_name('imageurl'); ?>" value="<?php echo $instance['imageurl']; ?>" />
19
  </div>
20
  <br clear="all" />
21
 
22
- <div id="<?php echo $this->get_field_id('fields'); ?>" <?php if ( empty($instance['attachment_id']) && empty($instance['imageurl']) ) { ?>style="display:none;"<?php } ?>>
23
- <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'image_widget'); ?>:</label>
24
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['title'])); ?>" /></p>
25
 
26
- <p><label for="<?php echo $this->get_field_id('alt'); ?>"><?php _e('Alternate Text', 'image_widget'); ?>:</label>
27
- <input class="widefat" id="<?php echo $this->get_field_id('alt'); ?>" name="<?php echo $this->get_field_name('alt'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['alt'])); ?>" /></p>
28
 
29
- <p><label for="<?php echo $this->get_field_id('rel'); ?>"><?php _e('Related', 'image_widget'); ?>:</label>
30
- <input class="widefat" id="<?php echo $this->get_field_id('rel'); ?>" name="<?php echo $this->get_field_name('rel'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['rel'])); ?>" /><br>
31
- <span class="description"><?php _e('A recommended HTML5 related terms list is availlable <a href="http://microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions" target="_blank">here</a>.', 'image_widget'); ?></span></p>
32
 
33
- <p><label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Caption', 'image_widget'); ?>:</label>
34
- <textarea rows="8" class="widefat" id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>"><?php echo format_to_edit($instance['description']); ?></textarea></p>
35
 
36
- <p><label for="<?php echo $this->get_field_id('link'); ?>"><?php _e('Link', 'image_widget'); ?>:</label>
37
- <input class="widefat" id="<?php echo $this->get_field_id('link'); ?>" name="<?php echo $this->get_field_name('link'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['link'])); ?>" /><br />
38
- <label for="<?php echo $this->get_field_id('linkid'); ?>"><?php _e('Link ID', 'image_widget'); ?>:</label>
39
- <input class="widefat" id="<?php echo $this->get_field_id('linkid'); ?>" name="<?php echo $this->get_field_name('linkid'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['linkid'])); ?>" /><br />
40
- <select name="<?php echo $this->get_field_name('linktarget'); ?>" id="<?php echo $this->get_field_id('linktarget'); ?>">
41
- <option value="_self"<?php selected( $instance['linktarget'], '_self' ); ?>><?php _e('Stay in Window', 'image_widget'); ?></option>
42
- <option value="_blank"<?php selected( $instance['linktarget'], '_blank' ); ?>><?php _e('Open New Window', 'image_widget'); ?></option>
43
  </select></p>
44
 
45
-
46
  <?php
47
  // Backwards compatibility prior to storing attachment ids
48
  ?>
49
- <div id="<?php echo $this->get_field_id('custom_size_selector'); ?>" <?php if ( empty($instance['attachment_id']) && !empty($instance['imageurl']) ) { $instance['size'] = self::CUSTOM_IMAGE_SIZE_SLUG; ?>style="display:none;"<?php } ?>>
50
- <p><label for="<?php echo $this->get_field_id('size'); ?>"><?php _e('Size', 'image_widget'); ?>:</label>
51
- <select name="<?php echo $this->get_field_name('size'); ?>" id="<?php echo $this->get_field_id('size'); ?>" onChange="imageWidget.toggleSizes( '<?php echo $this->id; ?>', '<?php echo $id_prefix; ?>' );">
52
- <?php foreach( $this->possible_image_sizes() as $size_key => $size_label ) : ?>
53
  <option value="<?php echo $size_key; ?>"<?php selected( $instance['size'], $size_key ); ?>><?php echo $size_label; ?></option>
54
  <?php endforeach ?>
55
  </select>
56
  </p>
57
  </div>
58
- <div id="<?php echo $this->get_field_id('custom_size_fields'); ?>" <?php if ( empty($instance['size']) || $instance['size']!=self::CUSTOM_IMAGE_SIZE_SLUG ) { ?>style="display:none;"<?php } ?>>
59
 
60
- <input type="hidden" id="<?php echo $this->get_field_id('aspect_ratio'); ?>" name="<?php echo $this->get_field_name('aspect_ratio'); ?>" value="<?php echo $this->get_image_aspect_ratio( $instance ); ?>" />
61
 
62
- <p><label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width', 'image_widget'); ?>:</label>
63
- <input id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['width'])); ?>" onchange="imageWidget.changeImgWidth( '<?php echo $this->id; ?>', '<?php echo $id_prefix; ?>' )" size="3" /></p>
64
 
65
- <p><label for="<?php echo $this->get_field_id('height'); ?>"><?php _e('Height', 'image_widget'); ?>:</label>
66
- <input id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['height'])); ?>" onchange="imageWidget.changeImgHeight( '<?php echo $this->id; ?>', '<?php echo $id_prefix; ?>' )" size="3" /></p>
67
 
68
  </div>
69
 
70
- <p><label for="<?php echo $this->get_field_id('align'); ?>"><?php _e('Align', 'image_widget'); ?>:</label>
71
- <select name="<?php echo $this->get_field_name('align'); ?>" id="<?php echo $this->get_field_id('align'); ?>">
72
- <option value="none"<?php selected( $instance['align'], 'none' ); ?>><?php _e('none', 'image_widget'); ?></option>
73
- <option value="left"<?php selected( $instance['align'], 'left' ); ?>><?php _e('left', 'image_widget'); ?></option>
74
- <option value="center"<?php selected( $instance['align'], 'center' ); ?>><?php _e('center', 'image_widget'); ?></option>
75
- <option value="right"<?php selected( $instance['align'], 'right' ); ?>><?php _e('right', 'image_widget'); ?></option>
76
  </select></p>
77
  </div>
4
  */
5
 
6
  // Block direct requests
7
+ if ( ! defined( 'ABSPATH' ) )
8
+ die( '-1' );
9
 
10
+ $id_prefix = $this->get_field_id( '' );
11
  ?>
12
  <div class="uploader">
13
+ <input type="submit" class="button" name="<?php echo $this->get_field_name( 'uploader_button' ); ?>" id="<?php echo $this->get_field_id( 'uploader_button' ); ?>" value="<?php _e( 'Select an Image', 'image-widget' ); ?>" onclick="imageWidget.uploader( '<?php echo $this->id; ?>', '<?php echo $id_prefix; ?>' ); return false;" />
14
+ <div class="tribe_preview" id="<?php echo $this->get_field_id( 'preview' ); ?>">
15
+ <?php echo $this->get_image_html( $instance, false ); ?>
16
  </div>
17
+ <input type="hidden" id="<?php echo $this->get_field_id( 'attachment_id' ); ?>" name="<?php echo $this->get_field_name( 'attachment_id' ); ?>" value="<?php echo abs( $instance['attachment_id'] ); ?>" />
18
+ <input type="hidden" id="<?php echo $this->get_field_id( 'imageurl' ); ?>" name="<?php echo $this->get_field_name( 'imageurl' ); ?>" value="<?php echo $instance['imageurl']; ?>" />
19
  </div>
20
  <br clear="all" />
21
 
22
+ <div id="<?php echo $this->get_field_id( 'fields' ); ?>" <?php if ( empty( $instance['attachment_id'] ) && empty( $instance['imageurl'] ) ) { ?>style="display:none;"<?php } ?>>
23
+ <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title', 'image-widget' ); ?>:</label>
24
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( strip_tags( $instance['title'] ) ); ?>" /></p>
25
 
26
+ <p><label for="<?php echo $this->get_field_id( 'alt' ); ?>"><?php _e( 'Alternate Text', 'image-widget' ); ?>:</label>
27
+ <input class="widefat" id="<?php echo $this->get_field_id( 'alt' ); ?>" name="<?php echo $this->get_field_name( 'alt' ); ?>" type="text" value="<?php echo esc_attr( strip_tags( $instance['alt'] ) ); ?>" /></p>
28
 
29
+ <p><label for="<?php echo $this->get_field_id( 'rel' ); ?>"><?php _e( 'Related', 'image-widget' ); ?>:</label>
30
+ <input class="widefat" id="<?php echo $this->get_field_id( 'rel' ); ?>" name="<?php echo $this->get_field_name( 'rel' ); ?>" type="text" value="<?php echo esc_attr( strip_tags( $instance['rel'] ) ); ?>" /><br>
31
+ <span class="description"><?php _e( 'A recommended HTML5 related terms list is available <a href="http://microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions" target="_blank">here</a>.', 'image-widget' ); ?></span></p>
32
 
33
+ <p><label for="<?php echo $this->get_field_id( 'description' ); ?>"><?php _e( 'Caption', 'image-widget' ); ?>:</label>
34
+ <textarea rows="8" class="widefat" id="<?php echo $this->get_field_id( 'description' ); ?>" name="<?php echo $this->get_field_name( 'description' ); ?>"><?php echo format_to_edit( $instance['description'] ); ?></textarea></p>
35
 
36
+ <p><label for="<?php echo $this->get_field_id( 'link' ); ?>"><?php _e( 'Link', 'image-widget' ); ?>:</label>
37
+ <input class="widefat" id="<?php echo $this->get_field_id( 'link' ); ?>" name="<?php echo $this->get_field_name( 'link' ); ?>" type="text" value="<?php echo esc_attr( strip_tags( $instance['link'] ) ); ?>" /><br />
38
+ <label for="<?php echo $this->get_field_id( 'linkid' ); ?>"><?php _e( 'Link ID', 'image-widget' ); ?>:</label>
39
+ <input class="widefat" id="<?php echo $this->get_field_id( 'linkid' ); ?>" name="<?php echo $this->get_field_name( 'linkid' ); ?>" type="text" value="<?php echo esc_attr( strip_tags( $instance['linkid'] ) ); ?>" /><br />
40
+ <select name="<?php echo $this->get_field_name( 'linktarget' ); ?>" id="<?php echo $this->get_field_id( 'linktarget' ); ?>">
41
+ <option value="_self"<?php selected( $instance['linktarget'], '_self' ); ?>><?php _e( 'Stay in Window', 'image-widget' ); ?></option>
42
+ <option value="_blank"<?php selected( $instance['linktarget'], '_blank' ); ?>><?php _e( 'Open New Window', 'image-widget' ); ?></option>
43
  </select></p>
44
 
 
45
  <?php
46
  // Backwards compatibility prior to storing attachment ids
47
  ?>
48
+ <div id="<?php echo $this->get_field_id( 'custom_size_selector' ); ?>" <?php if ( empty( $instance['attachment_id'] ) && ! empty( $instance['imageurl'] ) ) { $instance['size'] = self::CUSTOM_IMAGE_SIZE_SLUG; ?>style="display:none;"<?php } ?>>
49
+ <p><label for="<?php echo $this->get_field_id( 'size' ); ?>"><?php _e( 'Size', 'image-widget' ); ?>:</label>
50
+ <select name="<?php echo $this->get_field_name( 'size' ); ?>" id="<?php echo $this->get_field_id( 'size' ); ?>" onChange="imageWidget.toggleSizes( '<?php echo $this->id; ?>', '<?php echo $id_prefix; ?>' );">
51
+ <?php foreach ( $this->possible_image_sizes() as $size_key => $size_label ) : ?>
52
  <option value="<?php echo $size_key; ?>"<?php selected( $instance['size'], $size_key ); ?>><?php echo $size_label; ?></option>
53
  <?php endforeach ?>
54
  </select>
55
  </p>
56
  </div>
57
+ <div id="<?php echo $this->get_field_id( 'custom_size_fields' ); ?>" <?php if ( empty( $instance['size'] ) || $instance['size'] != self::CUSTOM_IMAGE_SIZE_SLUG ) { ?>style="display:none;"<?php } ?>>
58
 
59
+ <input type="hidden" id="<?php echo $this->get_field_id( 'aspect_ratio' ); ?>" name="<?php echo $this->get_field_name( 'aspect_ratio' ); ?>" value="<?php echo $this->get_image_aspect_ratio( $instance ); ?>" />
60
 
61
+ <p><label for="<?php echo $this->get_field_id( 'width' ); ?>"><?php _e( 'Width', 'image-widget' ); ?>:</label>
62
+ <input id="<?php echo $this->get_field_id( 'width' ); ?>" name="<?php echo $this->get_field_name( 'width' ); ?>" type="text" value="<?php echo esc_attr( strip_tags( $instance['width'] ) ); ?>" onchange="imageWidget.changeImgWidth( '<?php echo $this->id; ?>', '<?php echo $id_prefix; ?>' )" size="3" /></p>
63
 
64
+ <p><label for="<?php echo $this->get_field_id( 'height' ); ?>"><?php _e( 'Height', 'image-widget' ); ?>:</label>
65
+ <input id="<?php echo $this->get_field_id( 'height' ); ?>" name="<?php echo $this->get_field_name( 'height' ); ?>" type="text" value="<?php echo esc_attr( strip_tags( $instance['height'] ) ); ?>" onchange="imageWidget.changeImgHeight( '<?php echo $this->id; ?>', '<?php echo $id_prefix; ?>' )" size="3" /></p>
66
 
67
  </div>
68
 
69
+ <p><label for="<?php echo $this->get_field_id( 'align' ); ?>"><?php _e( 'Align', 'image-widget' ); ?>:</label>
70
+ <select name="<?php echo $this->get_field_name( 'align' ); ?>" id="<?php echo $this->get_field_id( 'align' ); ?>">
71
+ <option value="none"<?php selected( $instance['align'], 'none' ); ?>><?php _e( 'none', 'image-widget' ); ?></option>
72
+ <option value="left"<?php selected( $instance['align'], 'left' ); ?>><?php _e( 'left', 'image-widget' ); ?></option>
73
+ <option value="center"<?php selected( $instance['align'], 'center' ); ?>><?php _e( 'center', 'image-widget' ); ?></option>
74
+ <option value="right"<?php selected( $instance['align'], 'right' ); ?>><?php _e( 'right', 'image-widget' ); ?></option>
75
  </select></p>
76
  </div>
views/widget.php CHANGED
@@ -5,19 +5,18 @@
5
  */
6
 
7
  // Block direct requests
8
- if ( !defined('ABSPATH') )
9
- die('-1');
10
 
11
  echo $before_widget;
12
 
13
- if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }
14
 
15
  echo $this->get_image_html( $instance, true );
16
 
17
- if ( !empty( $description ) ) {
18
- echo '<div class="'.$this->widget_options['classname'].'-description" >';
19
  echo wpautop( $description );
20
- echo "</div>";
21
  }
22
  echo $after_widget;
23
- ?>
5
  */
6
 
7
  // Block direct requests
8
+ if ( ! defined( 'ABSPATH' ) )
9
+ die( '-1' );
10
 
11
  echo $before_widget;
12
 
13
+ if ( ! empty( $title ) ) { echo $before_title . $title . $after_title; }
14
 
15
  echo $this->get_image_html( $instance, true );
16
 
17
+ if ( ! empty( $description ) ) {
18
+ echo '<div class="' . esc_attr( $this->widget_options['classname'] ) . '-description" >';
19
  echo wpautop( $description );
20
+ echo '</div>';
21
  }
22
  echo $after_widget;