Instagram Slider Widget - Version 1.3.0

Version Description

  • Added Option to search for hashtags
  • Added Limit for number of words to appear in caption
  • Fixed 500 server error that accured when loading 15+ images
  • Fixed css for some themes
Download this release

Release Info

Developer jetonr
Plugin Icon 128x128 Instagram Slider Widget
Version 1.3.0
Comparing to
See all releases

Code changes from version 1.2.3 to 1.3.0

assets/css/instag-slider.css CHANGED
@@ -56,29 +56,30 @@
56
  .jr-insta-thumb ul.thumbnails.no-border { margin-left: 0; }
57
  .jr-insta-thumb ul.thumbnails li { display: inline-block; padding: 0; margin: 0 0 2.5% 2.5%; background: none; border: 0; vertical-align: top; box-shadow: none; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; }
58
  .jr-insta-thumb ul.thumbnails.no-border li { margin: 0; }
59
- .jr-insta-thumb ul.thumbnails li img { max-width: 100%; height: auto; margin: 0; border: 0; vertical-align: top; }
 
60
 
61
- .jr-insta-thumb ul.thumbnails.jr_col_1 li { width: 97.5%; } /* this value + 2.5 should = 100% */
62
- .jr-insta-thumb ul.thumbnails.jr_col_2 li { width: 47.5%; } /* this value + 2.5 should = 50% */
63
- .jr-insta-thumb ul.thumbnails.jr_col_3 li { width: 30.83%; } /* this value + 2.5 should = 33% */
64
- .jr-insta-thumb ul.thumbnails.jr_col_4 li { width: 22.5%; } /* this value + 2.5 should = 25% */
65
- .jr-insta-thumb ul.thumbnails.jr_col_5 li { width: 17.5%; } /* this value + 2.5 should = 20% */
66
- .jr-insta-thumb ul.thumbnails.jr_col_6 li { width: 14.17%; } /* this value + 2.5 should = 16.66% */
67
- .jr-insta-thumb ul.thumbnails.jr_col_7 li { width: 11.78%; } /* this value + 2.5 should = 14.28% */
68
- .jr-insta-thumb ul.thumbnails.jr_col_8 li { width: 10%; } /* this value + 2.5 should = 12.5% */
69
- .jr-insta-thumb ul.thumbnails.jr_col_9 li { width: 8.61%; } /* this value + 2.5 should = 11.11% */
70
- .jr-insta-thumb ul.thumbnails.jr_col_10 li { width: 7.5%; } /* this value + 2.5 should = 10% */
71
 
72
- .jr-insta-thumb ul.thumbnails.no-border.jr_col_1 li { width: 100%; }
73
- .jr-insta-thumb ul.thumbnails.no-border.jr_col_2 li { width: 50%; }
74
- .jr-insta-thumb ul.thumbnails.no-border.jr_col_3 li { width: 33.33%; }
75
- .jr-insta-thumb ul.thumbnails.no-border.jr_col_4 li { width: 25%; }
76
- .jr-insta-thumb ul.thumbnails.no-border.jr_col_5 li { width: 20%; }
77
- .jr-insta-thumb ul.thumbnails.no-border.jr_col_6 li { width: 16.66%; }
78
- .jr-insta-thumb ul.thumbnails.no-border.jr_col_7 li { width: 14.28%; }
79
- .jr-insta-thumb ul.thumbnails.no-border.jr_col_8 li { width: 12.5%; }
80
- .jr-insta-thumb ul.thumbnails.no-border.jr_col_9 li { width: 11.11%; }
81
- .jr-insta-thumb ul.thumbnails.no-border.jr_col_10 li { width: 10%; }
82
 
83
  @media all and (max-width: 640px){
84
  /* Make 3-6 cols into 2 col */
@@ -86,14 +87,14 @@
86
  .jr-insta-thumb ul.thumbnails.jr_col_4 li,
87
  .jr-insta-thumb ul.thumbnails.jr_col_5 li,
88
  .jr-insta-thumb ul.thumbnails.jr_col_6 li{
89
- width: 47.5%;
90
  }
91
  /* Make 7-10 cols into 4 col */
92
  .jr-insta-thumb ul.thumbnails.jr_col_7 li,
93
  .jr-insta-thumb ul.thumbnails.jr_col_8 li,
94
  .jr-insta-thumb ul.thumbnails.jr_col_9 li,
95
  .jr-insta-thumb ul.thumbnails.jr_col_10 li{
96
- width: 22.5%;
97
  }
98
 
99
  /* Make 3-6 cols into 2 col */
@@ -101,14 +102,14 @@
101
  .jr-insta-thumb ul.thumbnails.no-border.jr_col_4 li,
102
  .jr-insta-thumb ul.thumbnails.no-border.jr_col_5 li,
103
  .jr-insta-thumb ul.thumbnails.no-border.jr_col_6 li{
104
- width: 50%;
105
  }
106
  /* Make 7-10 cols into 4 col */
107
  .jr-insta-thumb ul.thumbnails.no-border.jr_col_7 li,
108
  .jr-insta-thumb ul.thumbnails.no-border.jr_col_8 li,
109
  .jr-insta-thumb ul.thumbnails.no-border.jr_col_9 li,
110
  .jr-insta-thumb ul.thumbnails.no-border.jr_col_10 li{
111
- width: 25%;
112
  }
113
 
114
  }
56
  .jr-insta-thumb ul.thumbnails.no-border { margin-left: 0; }
57
  .jr-insta-thumb ul.thumbnails li { display: inline-block; padding: 0; margin: 0 0 2.5% 2.5%; background: none; border: 0; vertical-align: top; box-shadow: none; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; }
58
  .jr-insta-thumb ul.thumbnails.no-border li { margin: 0; }
59
+ .jr-insta-thumb ul.thumbnails li img { max-width: 100% !important; height: auto !important; margin: 0 !important; border: 0 !important; vertical-align: top; }
60
+ .jr-insta-thumb ul.thumbnails li a { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline; }
61
 
62
+ .jr-insta-thumb ul.thumbnails.jr_col_1 li { width: 97.5% !important; } /* this value + 2.5 should = 100% */
63
+ .jr-insta-thumb ul.thumbnails.jr_col_2 li { width: 47.5% !important; } /* this value + 2.5 should = 50% */
64
+ .jr-insta-thumb ul.thumbnails.jr_col_3 li { width: 30.83% !important; } /* this value + 2.5 should = 33% */
65
+ .jr-insta-thumb ul.thumbnails.jr_col_4 li { width: 22.5% !important; } /* this value + 2.5 should = 25% */
66
+ .jr-insta-thumb ul.thumbnails.jr_col_5 li { width: 17.5% !important; } /* this value + 2.5 should = 20% */
67
+ .jr-insta-thumb ul.thumbnails.jr_col_6 li { width: 14.17% !important; } /* this value + 2.5 should = 16.66% */
68
+ .jr-insta-thumb ul.thumbnails.jr_col_7 li { width: 11.78% !important; } /* this value + 2.5 should = 14.28% */
69
+ .jr-insta-thumb ul.thumbnails.jr_col_8 li { width: 10% !important; } /* this value + 2.5 should = 12.5% */
70
+ .jr-insta-thumb ul.thumbnails.jr_col_9 li { width: 8.61% !important; } /* this value + 2.5 should = 11.11% */
71
+ .jr-insta-thumb ul.thumbnails.jr_col_10 li { width: 7.5% !important; } /* this value + 2.5 should = 10% */
72
 
73
+ .jr-insta-thumb ul.thumbnails.no-border.jr_col_1 li { width: 100% !important; }
74
+ .jr-insta-thumb ul.thumbnails.no-border.jr_col_2 li { width: 50% !important; }
75
+ .jr-insta-thumb ul.thumbnails.no-border.jr_col_3 li { width: 33.33% !important; }
76
+ .jr-insta-thumb ul.thumbnails.no-border.jr_col_4 li { width: 25% !important; }
77
+ .jr-insta-thumb ul.thumbnails.no-border.jr_col_5 li { width: 20% !important; }
78
+ .jr-insta-thumb ul.thumbnails.no-border.jr_col_6 li { width: 16.66% !important; }
79
+ .jr-insta-thumb ul.thumbnails.no-border.jr_col_7 li { width: 14.28% !important; }
80
+ .jr-insta-thumb ul.thumbnails.no-border.jr_col_8 li { width: 12.5% !important; }
81
+ .jr-insta-thumb ul.thumbnails.no-border.jr_col_9 li { width: 11.11% !important; }
82
+ .jr-insta-thumb ul.thumbnails.no-border.jr_col_10 li { width: 10% !important; }
83
 
84
  @media all and (max-width: 640px){
85
  /* Make 3-6 cols into 2 col */
87
  .jr-insta-thumb ul.thumbnails.jr_col_4 li,
88
  .jr-insta-thumb ul.thumbnails.jr_col_5 li,
89
  .jr-insta-thumb ul.thumbnails.jr_col_6 li{
90
+ width: 47.5% !important;;
91
  }
92
  /* Make 7-10 cols into 4 col */
93
  .jr-insta-thumb ul.thumbnails.jr_col_7 li,
94
  .jr-insta-thumb ul.thumbnails.jr_col_8 li,
95
  .jr-insta-thumb ul.thumbnails.jr_col_9 li,
96
  .jr-insta-thumb ul.thumbnails.jr_col_10 li{
97
+ width: 22.5% !important;;
98
  }
99
 
100
  /* Make 3-6 cols into 2 col */
102
  .jr-insta-thumb ul.thumbnails.no-border.jr_col_4 li,
103
  .jr-insta-thumb ul.thumbnails.no-border.jr_col_5 li,
104
  .jr-insta-thumb ul.thumbnails.no-border.jr_col_6 li{
105
+ width: 50% !important;;
106
  }
107
  /* Make 7-10 cols into 4 col */
108
  .jr-insta-thumb ul.thumbnails.no-border.jr_col_7 li,
109
  .jr-insta-thumb ul.thumbnails.no-border.jr_col_8 li,
110
  .jr-insta-thumb ul.thumbnails.no-border.jr_col_9 li,
111
  .jr-insta-thumb ul.thumbnails.no-border.jr_col_10 li{
112
+ width: 25% !important;;
113
  }
114
 
115
  }
assets/css/jr-insta-admin.css CHANGED
@@ -7,6 +7,9 @@
7
  .jr-container .pressthis a:hover, .jr-container .pressthis-bookmarklet a:hover { cursor: pointer; background: #53b5d9; border: 1px solid #0074a2; color: #ffffff; font-weight: bold }
8
  .jr-container .jr_insta_error { border-left: 4px solid #dd3d36; -moz-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1); -webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1); box-shadow: 0 1px 1px 0 rgba(0,0,0,.1); padding: 5px 12px; }
9
  .jr-container .jr-radio { margin-right: 20px }
 
 
 
10
  .jr-container .jr-advanced { text-decoration: none; border: none }
11
  .jr-container .jr-advanced:focus { outline: 0; border: none; box-shadow:none }
12
 
7
  .jr-container .pressthis a:hover, .jr-container .pressthis-bookmarklet a:hover { cursor: pointer; background: #53b5d9; border: 1px solid #0074a2; color: #ffffff; font-weight: bold }
8
  .jr-container .jr_insta_error { border-left: 4px solid #dd3d36; -moz-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1); -webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1); box-shadow: 0 1px 1px 0 rgba(0,0,0,.1); padding: 5px 12px; }
9
  .jr-container .jr-radio { margin-right: 20px }
10
+ .jr-container .jr-search-for-container { display: block; margin-bottom: 7px; }
11
+ .jr-container .jr-seach-for { width: 90px; display: inline-block; vertical-align: middle }
12
+
13
  .jr-container .jr-advanced { text-decoration: none; border: none }
14
  .jr-container .jr-advanced:focus { outline: 0; border: none; box-shadow:none }
15
 
assets/js/jr-insta-admin.js CHANGED
@@ -24,6 +24,31 @@
24
  }
25
  });
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  // Hide Refresh hour if source is wp media library
28
  $('body').on('change', '.jr-container input:radio[id$="source"]', function(e){
29
  var source = $(this);
@@ -34,6 +59,10 @@
34
  source.closest('.jr-container').find('.jr-instagram-option').animate({opacity: 'hide' , height: 'hide'}, 200);
35
  source.closest('.jr-container').find('.blocked-wrap').animate({opacity: 'hide' , height: 'hide'}, 200);
36
  source.closest('.jr-container').find('input[id$="attachment"]').closest('p').animate({opacity: 'hide' , height: 'hide'}, 200);
 
 
 
 
37
  } else {
38
  source.closest('.jr-container').find('input[id$="refresh_hour"]').closest('p').animate({opacity: 'show' , height: 'show'}, 200);
39
  source.closest('.jr-container').find('input[id$="attachment"]').closest('p').animate({opacity: 'show' , height: 'show'}, 200);
@@ -49,8 +78,14 @@
49
  var attachment = $(this);
50
  if ( this.checked ) {
51
  attachment.closest('.jr-container').find('.blocked-wrap').animate({opacity: 'show' , height: 'show'}, 200);
 
 
 
52
  } else {
53
  attachment.closest('.jr-container').find('.blocked-wrap').animate({opacity: 'hide' , height: 'hide'}, 200);
 
 
 
54
  }
55
  });
56
 
24
  }
25
  });
26
 
27
+ // Modfiy options when search for is changed
28
+ $('body').on('change', '.jr-container input:radio[id$="search_for"]', function(e){
29
+ var search_for = $(this);
30
+ if ( search_for.val() != 'username' ) {
31
+ search_for.closest('.jr-container').find('input[id$="source"]').closest('p').animate({opacity: 'hide' , height: 'hide'}, 200);
32
+ search_for.closest('.jr-container').find('[id$="attachment"]:checkbox').closest('p').animate({opacity: 'hide' , height: 'hide'}, 200);
33
+ search_for.closest('.jr-container').find('select[id$="images_link"] option[value="local_image_url"]').animate({opacity: 'hide' , height: 'hide'}, 200);
34
+ search_for.closest('.jr-container').find('select[id$="images_link"] option[value="user_url"]').animate({opacity: 'hide' , height: 'hide'}, 200);
35
+ search_for.closest('.jr-container').find('select[id$="images_link"] option[value="attachment"]').animate({opacity: 'hide' , height: 'hide'}, 200);
36
+ search_for.closest('.jr-container').find('select[id$="images_link"]').val('image_url');
37
+ search_for.closest('.jr-container').find('select[id$="description"] option[value="username"]').animate({opacity: 'hide' , height: 'hide'}, 200);
38
+
39
+ } else {
40
+ search_for.closest('.jr-container').find('input[id$="source"]').closest('p').animate({opacity: 'show' , height: 'show'}, 200);
41
+ if ( search_for.closest('.jr-container').find('input:radio[id$="source"]:checked').val() == 'instagram' ) {
42
+ search_for.closest('.jr-container').find('[id$="attachment"]:checkbox').closest('p').animate({opacity: 'show' , height: 'show'}, 200);
43
+ }
44
+ search_for.closest('.jr-container').find('select[id$="images_link"] option[value="local_image_url"]').animate({opacity: 'show' , height: 'show'}, 200);
45
+ search_for.closest('.jr-container').find('select[id$="images_link"] option[value="user_url"]').animate({opacity: 'show' , height: 'show'}, 200);
46
+ search_for.closest('.jr-container').find('select[id$="images_link"] option[value="attachment"]').animate({opacity: 'show' , height: 'show'}, 200);
47
+ search_for.closest('.jr-container').find('select[id$="images_link"]').val('image_url');
48
+ search_for.closest('.jr-container').find('select[id$="description"] option[value="username"]').animate({opacity: 'show' , height: 'show'}, 200);
49
+ }
50
+ });
51
+
52
  // Hide Refresh hour if source is wp media library
53
  $('body').on('change', '.jr-container input:radio[id$="source"]', function(e){
54
  var source = $(this);
59
  source.closest('.jr-container').find('.jr-instagram-option').animate({opacity: 'hide' , height: 'hide'}, 200);
60
  source.closest('.jr-container').find('.blocked-wrap').animate({opacity: 'hide' , height: 'hide'}, 200);
61
  source.closest('.jr-container').find('input[id$="attachment"]').closest('p').animate({opacity: 'hide' , height: 'hide'}, 200);
62
+ source.closest('.jr-container').find('select[id$="images_link"] option[value="local_image_url"]').animate({opacity: 'show' , height: 'show'}, 200);
63
+ source.closest('.jr-container').find('select[id$="images_link"] option[value="user_url"]').animate({opacity: 'show' , height: 'show'}, 200);
64
+ source.closest('.jr-container').find('select[id$="images_link"] option[value="attachment"]').animate({opacity: 'show' , height: 'show'}, 200);
65
+ source.closest('.jr-container').find('select[id$="images_link"]').val('image_url');
66
  } else {
67
  source.closest('.jr-container').find('input[id$="refresh_hour"]').closest('p').animate({opacity: 'show' , height: 'show'}, 200);
68
  source.closest('.jr-container').find('input[id$="attachment"]').closest('p').animate({opacity: 'show' , height: 'show'}, 200);
78
  var attachment = $(this);
79
  if ( this.checked ) {
80
  attachment.closest('.jr-container').find('.blocked-wrap').animate({opacity: 'show' , height: 'show'}, 200);
81
+ attachment.closest('.jr-container').find('select[id$="images_link"] option[value="local_image_url"]').animate({opacity: 'show' , height: 'show'}, 200);
82
+ attachment.closest('.jr-container').find('select[id$="images_link"] option[value="attachment"]').animate({opacity: 'show' , height: 'show'}, 200);
83
+ attachment.closest('.jr-container').find('select[id$="images_link"]').val('image_url');
84
  } else {
85
  attachment.closest('.jr-container').find('.blocked-wrap').animate({opacity: 'hide' , height: 'hide'}, 200);
86
+ attachment.closest('.jr-container').find('select[id$="images_link"] option[value="local_image_url"]').animate({opacity: 'hide' , height: 'hide'}, 200);
87
+ attachment.closest('.jr-container').find('select[id$="images_link"] option[value="attachment"]').animate({opacity: 'hide' , height: 'hide'}, 200);
88
+ attachment.closest('.jr-container').find('select[id$="images_link"]').val('image_url');
89
  }
90
  });
91
 
instaram_slider.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Instagram Slider Widget
4
  Plugin URI: http://jrwebstudio.com/instagram-slider/
5
- Version: 1.2.3
6
  Description: Instagram Slider Widget is a responsive slider widget that shows 20 latest images from a public instagram user.
7
  Author: jetonr
8
  Author URI: http://jrwebstudio.com/
@@ -24,7 +24,7 @@ class JR_InstagramSlider extends WP_Widget {
24
  *
25
  * @var string
26
  */
27
- const VERSION = '1.2.3';
28
 
29
  /**
30
  * Initialize the plugin by registering widget and loading public scripts
@@ -136,7 +136,9 @@ class JR_InstagramSlider extends WP_Widget {
136
  public function update( $new_instance, $instance ) {
137
 
138
  $instance['title'] = strip_tags( $new_instance['title'] );
 
139
  $instance['username'] = $new_instance['username'];
 
140
  $instance['source'] = $new_instance['source'];
141
  $instance['attachment'] = $new_instance['attachment'];
142
  $instance['template'] = $new_instance['template'];
@@ -151,6 +153,7 @@ class JR_InstagramSlider extends WP_Widget {
151
  $instance['image_link_class'] = $new_instance['image_link_class'];
152
  $instance['controls'] = $new_instance['controls'];
153
  $instance['animation'] = $new_instance['animation'];
 
154
  $instance['slidespeed'] = $new_instance['slidespeed'];
155
  $instance['description'] = $new_instance['description'];
156
 
@@ -167,7 +170,9 @@ class JR_InstagramSlider extends WP_Widget {
167
 
168
  $defaults = array(
169
  'title' => __('Instagram Slider', 'jrinstaslider'),
 
170
  'username' => '',
 
171
  'source' => 'instagram',
172
  'attachment' => 1,
173
  'template' => 'slider',
@@ -177,11 +182,12 @@ class JR_InstagramSlider extends WP_Widget {
177
  'images_number' => 5,
178
  'columns' => 4,
179
  'refresh_hour' => 5,
180
- 'image_size' => 'full',
181
  'image_link_rel' => '',
182
  'image_link_class' => '',
183
  'controls' => 'prev_next',
184
  'animation' => 'slide',
 
185
  'slidespeed' => 7000,
186
  'description' => array( 'username', 'time','caption' )
187
  );
@@ -191,18 +197,20 @@ class JR_InstagramSlider extends WP_Widget {
191
  ?>
192
  <div class="jr-container">
193
  <p>
194
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'jrinstaslider'); ?></label>
195
  <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" />
196
  </p>
197
  <p>
198
- <label for="<?php echo $this->get_field_id( 'username' ); ?>"><?php _e('Instagram Username:', 'jrinstaslider'); ?></label>
199
- <input class="widefat" id="<?php echo $this->get_field_id( 'username' ); ?>" name="<?php echo $this->get_field_name( 'username' ); ?>" value="<?php echo $instance['username']; ?>" />
 
200
  </p>
201
- <p>
202
- <?php _e( 'Source:', 'jrinstaslider' ); ?><br>
203
  <label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'source' ); ?>" name="<?php echo $this->get_field_name( 'source' ); ?>" value="instagram" <?php checked( 'instagram', $instance['source'] ); ?> /> <?php _e( 'Instagram', 'jrinstaslider' ); ?></label>
204
  <label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'source' ); ?>" name="<?php echo $this->get_field_name( 'source' ); ?>" value="media_library" <?php checked( 'media_library', $instance['source'] ); ?> /> <?php _e( 'WP Media Library', 'jrinstaslider' ); ?></label>
205
  <?php
 
206
  $saved_images = 0;
207
  $username = '';
208
 
@@ -215,7 +223,6 @@ class JR_InstagramSlider extends WP_Widget {
215
  $insta_option_class = 'hide-instagram';
216
  }
217
 
218
-
219
  if ( isset( $instance['username'] ) && ( !empty( $instance['username'] ) ) ) {
220
  $username = $instance['username'];
221
  $savedinsta_args = array(
@@ -245,25 +252,25 @@ class JR_InstagramSlider extends WP_Widget {
245
  echo '<span class="jr-description jr-instagram-option '.$insta_option_class.'"><strong>Instagram</strong> can display up to <strong>24</strong> images for <strong>'. $username .'</strong>!<br> This option will check for new images on Instagram!</span>';
246
  ?>
247
  </p>
248
- <p class="<?php if ( 'instagram' != $instance['source'] ) echo 'hidden'; ?>">
249
- <label for="<?php echo $this->get_field_id( 'attachment' ); ?>"><?php _e( 'Save and Display Images from Media Library:', 'jrinstaslider' ); ?></label>
250
  <input class="widefat" id="<?php echo $this->get_field_id( 'attachment' ); ?>" name="<?php echo $this->get_field_name( 'attachment' ); ?>" type="checkbox" value="1" <?php checked( '1', $instance['attachment'] ); ?> />
251
  <br><span class="jr-description"><?php _e( 'It is recommended you check the field above because images displayed directly from Instagram server will affect your site loading time!', 'jrinstaslider') ?></span>
252
  </p>
253
  <p>
254
- <label for="<?php echo $this->get_field_id( 'images_number' ); ?>"><?php _e( 'Number of images to show:', 'jrinstaslider' ); ?>
255
  <input class="small-text" id="<?php echo $this->get_field_id( 'images_number' ); ?>" name="<?php echo $this->get_field_name( 'images_number' ); ?>" value="<?php echo $instance['images_number']; ?>" />
256
  </label>
257
  </p>
258
  <p class="<?php if ( 'instagram' != $instance['source'] ) echo 'hidden'; ?>">
259
- <label for="<?php echo $this->get_field_id( 'refresh_hour' ); ?>"><?php _e( 'Check for new images every:', 'jrinstaslider' ); ?>
260
  <input class="small-text" id="<?php echo $this->get_field_id( 'refresh_hour' ); ?>" name="<?php echo $this->get_field_name( 'refresh_hour' ); ?>" value="<?php echo $instance['refresh_hour']; ?>" />
261
  <span><?php _e('hours', 'jrinstaslider'); ?></span>
262
  </label>
263
  </p>
264
  <?php
265
  $user_opt = get_option( 'jr_insta_'. md5( $instance['username'] ) );
266
- if ( isset( $user_opt['deleted_images'] ) && ( !empty( $user_opt['deleted_images'] ) && ( $instance['source'] == 'instagram' ) && ( $instance['attachment'] ) ) ) {
267
  $deleted_count = count( $user_opt['deleted_images'] );
268
  echo '<div class="blocked-wrap">';
269
  wp_nonce_field( 'jr_unblock_instagram_image', 'unblock_images_nonce' );
@@ -281,7 +288,7 @@ class JR_InstagramSlider extends WP_Widget {
281
  }
282
  ?>
283
  <p>
284
- <label for="<?php echo $this->get_field_id( 'template' ); ?>"><?php _e( 'Template', 'jrinstaslider' ); ?>
285
  <select class="widefat" name="<?php echo $this->get_field_name( 'template' ); ?>" id="<?php echo $this->get_field_id( 'template' ); ?>">
286
  <option value="slider" <?php echo ($instance['template'] == 'slider') ? ' selected="selected"' : ''; ?>><?php _e( 'Slider - Normal', 'jrinstaslider' ); ?></option>
287
  <option value="slider-overlay" <?php echo ($instance['template'] == 'slider-overlay') ? ' selected="selected"' : ''; ?>><?php _e( 'Slider - Overlay Text', 'jrinstaslider' ); ?></option>
@@ -291,7 +298,7 @@ class JR_InstagramSlider extends WP_Widget {
291
  </label>
292
  </p>
293
  <p class="<?php if ( 'thumbs' != $instance['template'] && 'thumbs-no-border' != $instance['template'] ) echo 'hidden'; ?>">
294
- <label for="<?php echo $this->get_field_id( 'columns' ); ?>"><?php _e( 'Number of Columns:', 'jrinstaslider' ); ?>
295
  <input class="small-text" id="<?php echo $this->get_field_id( 'columns' ); ?>" name="<?php echo $this->get_field_name( 'columns' ); ?>" value="<?php echo $instance['columns']; ?>" />
296
  <span class='jr-description'><?php _e('max is 10 ( only for thumbnails template )', 'jrinstaslider'); ?></span>
297
  </label>
@@ -306,7 +313,7 @@ class JR_InstagramSlider extends WP_Widget {
306
  }
307
  */
308
  ?>
309
- <label for="<?php echo $this->get_field_id( 'image_size' ); ?>"><?php _e( 'Image size', 'jrinstaslider' ); ?></label>
310
  <select class="widefat" id="<?php echo $this->get_field_id( 'image_size' ); ?>" name="<?php echo $this->get_field_name( 'image_size' ); ?>">
311
  <option value=""><?php _e('Select Image Size', 'jrinstaslider') ?></option>
312
  <?php
@@ -322,7 +329,7 @@ class JR_InstagramSlider extends WP_Widget {
322
  </select>
323
  </p>
324
  <p>
325
- <label for="<?php echo $this->get_field_id( 'orderby' ); ?>"><?php _e( 'Order by', 'jrinstaslider' ); ?>
326
  <select class="widefat" name="<?php echo $this->get_field_name( 'orderby' ); ?>" id="<?php echo $this->get_field_id( 'orderby' ); ?>">
327
  <option value="date-ASC" <?php selected( $instance['orderby'], 'date-ASC', true); ?>><?php _e( 'Date - Ascending', 'jrinstaslider' ); ?></option>
328
  <option value="date-DESC" <?php selected( $instance['orderby'], 'date-DESC', true); ?>><?php _e( 'Date - Descending', 'jrinstaslider' ); ?></option>
@@ -333,14 +340,12 @@ class JR_InstagramSlider extends WP_Widget {
333
  </label>
334
  </p>
335
  <p>
336
- <label for="<?php echo $this->get_field_id( 'images_link' ); ?>"><?php _e( 'Link to', 'jrinstaslider' ); ?>
337
  <select class="widefat" name="<?php echo $this->get_field_name( 'images_link' ); ?>" id="<?php echo $this->get_field_id( 'images_link' ); ?>">
338
  <option value="image_url" <?php selected( $instance['images_link'], 'image_url', true); ?>><?php _e( 'Instagram Image', 'jrinstaslider' ); ?></option>
339
- <option value="user_url" <?php selected( $instance['images_link'], 'user_url', true); ?>><?php _e( 'Instagram Profile', 'jrinstaslider' ); ?></option>
340
- <?php if ( $instance['attachment'] ) : ?>
341
- <option value="local_image_url" <?php selected( $instance['images_link'], 'local_image_url', true); ?>><?php _e( 'Locally Saved Image', 'jrinstaslider' ); ?></option>
342
- <option value="attachment" <?php selected( $instance['images_link'], 'attachment', true); ?>><?php _e( 'Attachment Page', 'jrinstaslider' ); ?></option>
343
- <?php endif; ?>
344
  <option value="custom_url" <?php selected( $instance['images_link'], 'custom_url', true ); ?>><?php _e( 'Custom Link', 'jrinstaslider' ); ?></option>
345
  <option value="none" <?php selected( $instance['images_link'], 'none', true); ?>><?php _e( 'None', 'jrinstaslider' ); ?></option>
346
  </select>
@@ -391,6 +396,11 @@ class JR_InstagramSlider extends WP_Widget {
391
  <label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'animation' ); ?>" name="<?php echo $this->get_field_name( 'animation' ); ?>" value="slide" <?php checked( 'slide', $instance['animation'] ); ?> /> <?php _e( 'Slide', 'jrinstaslider' ); ?></label>
392
  <label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'animation' ); ?>" name="<?php echo $this->get_field_name( 'animation' ); ?>" value="fade" <?php checked( 'fade', $instance['animation'] ); ?> /> <?php _e( 'Fade', 'jrinstaslider' ); ?></label>
393
  </p>
 
 
 
 
 
394
  <p>
395
  <label for="<?php echo $this->get_field_id( 'slidespeed' ); ?>"><?php _e( 'Slide Speed:', 'jrinstaslider' ); ?>
396
  <input class="small-text" id="<?php echo $this->get_field_id( 'slidespeed' ); ?>" name="<?php echo $this->get_field_name( 'slidespeed' ); ?>" value="<?php echo $instance['slidespeed']; ?>" />
@@ -401,7 +411,7 @@ class JR_InstagramSlider extends WP_Widget {
401
  <p>
402
  <label for="<?php echo $this->get_field_id('description'); ?>"><?php _e( 'Slider Text Description:', 'jrinstaslider' ); ?></label>
403
  <select size=3 class='widefat' id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>[]" multiple="multiple">
404
- <option value='username' <?php $this->selected( $instance['description'], 'username' ); ?>><?php _e( 'Username', 'jrinstaslider'); ?></option>
405
  <option value='time'<?php $this->selected( $instance['description'], 'time' ); ?>><?php _e( 'Time', 'jrinstaslider'); ?></option>
406
  <option value='caption'<?php $this->selected( $instance['description'], 'caption' ); ?>><?php _e( 'Caption', 'jrinstaslider'); ?></option>
407
  </select>
@@ -470,8 +480,9 @@ class JR_InstagramSlider extends WP_Widget {
470
  * @return string
471
  */
472
  private function display_images( $args ) {
473
-
474
  $username = isset( $args['username'] ) && !empty( $args['username'] ) ? $args['username'] : false;
 
475
  $source = isset( $args['source'] ) && !empty( $args['source'] ) ? $args['source'] : 'instagram';
476
  $attachment = isset( $args['attachment'] ) ? true : false;
477
  $template = isset( $args['template'] ) ? $args['template'] : 'slider';
@@ -481,33 +492,40 @@ class JR_InstagramSlider extends WP_Widget {
481
  $images_number = isset( $args['images_number'] ) ? absint( $args['images_number'] ) : 5;
482
  $columns = isset( $args['columns'] ) ? absint( $args['columns'] ) : 4;
483
  $refresh_hour = isset( $args['refresh_hour'] ) ? absint( $args['refresh_hour'] ) : 5;
484
- $image_size = isset( $args['image_size'] ) ? $args['image_size'] : 'full';
485
  $image_link_rel = isset( $args['image_link_rel'] ) ? $args['image_link_rel'] : '';
486
  $image_link_class = isset( $args['image_link_class'] ) ? $args['image_link_class'] : '';
487
  $controls = isset( $args['controls'] ) ? $args['controls'] : 'prev_next';
488
  $animation = isset( $args['animation'] ) ? $args['animation'] : 'slide';
 
489
  $slidespeed = isset( $args['slidespeed'] ) ? $args['slidespeed'] : 7000;
490
  $description = isset( $args['description'] ) ? $args['description'] : array();
491
  $widget_id = isset( $args['widget_id'] ) ? $args['widget_id'] : preg_replace( '/[^0-9]/', '', $this->id );
492
 
493
- if ( false == $username ) {
494
- return false;
495
- }
496
-
497
  if ( !empty( $description ) && !is_array( $description ) ) {
498
  $description = explode( ',', $description );
499
  }
500
 
 
 
 
 
 
 
 
 
501
  if ( $source == 'instagram' && $refresh_hour == 0 ) {
502
  $refresh_hour = 5;
503
  }
504
 
505
  $template_args = array(
506
- 'source' => $source,
507
- 'attachment' => $attachment,
508
- 'image_size' => $image_size,
509
- 'link_rel' => $image_link_rel,
510
- 'link_class' => $image_link_class
 
 
511
  );
512
 
513
  $images_div_class = 'jr-insta-thumb';
@@ -567,9 +585,9 @@ class JR_InstagramSlider extends WP_Widget {
567
  $images_div = "<div class='{$images_div_class}'>\n";
568
  $images_ul = "<ul class='no-bullet {$ul_class}'>\n";
569
 
570
- $output = __( 'No saved images for ' . $username, 'jrinstaslider' );
571
 
572
- if ( ( $attachment && $source == 'instagram' ) || ( $source == 'media_library') ) {
573
 
574
  $query_args = array(
575
  'post_type' => 'attachment',
@@ -602,13 +620,13 @@ class JR_InstagramSlider extends WP_Widget {
602
 
603
  } else {
604
 
605
- $attachment_ids = $this->instagram_data( $username, $refresh_hour, $images_number, true );
606
 
607
  if ( is_array( $attachment_ids ) && !empty( $attachment_ids ) ) {
608
  $query_args['post__in'] = $attachment_ids;
609
  } else {
610
  if ( is_array( $attachment_ids ) ) {
611
- return __( 'No Images found for this user. This account may not be public!', 'jrinstaslider' );
612
  } else {
613
  return $attachment_ids;
614
  }
@@ -648,7 +666,7 @@ class JR_InstagramSlider extends WP_Widget {
648
 
649
  } else {
650
 
651
- $images_data = $this->instagram_data( $username, $refresh_hour, $images_number, false );
652
 
653
  if ( is_array( $images_data ) && !empty( $images_data ) ) {
654
 
@@ -686,9 +704,9 @@ class JR_InstagramSlider extends WP_Widget {
686
  $template_args['image'] = $image_data['url'];
687
  }
688
 
689
- $template_args['caption'] = $image_data['caption'];
690
- $template_args['timestamp'] = $image_data['timestamp'];
691
- $template_args['username'] = $image_data['username'];
692
 
693
  $output .= $this->get_template( $template, $template_args );
694
  }
@@ -713,7 +731,7 @@ class JR_InstagramSlider extends WP_Widget {
713
 
714
  $link_to = isset( $args['link_to'] ) ? $args['link_to'] : false;
715
 
716
- if ( $args['attachment'] !== true && $args['source'] == 'instagram' ) {
717
  $caption = $args['caption'];
718
  $time = $args['timestamp'];
719
  $username = $args['username'];
@@ -729,6 +747,7 @@ class JR_InstagramSlider extends WP_Widget {
729
 
730
  $short_caption = wp_trim_words( $caption, 10 );
731
  $short_caption = preg_replace("/[^A-Za-z0-9?! ]/","", $short_caption);
 
732
 
733
  $image_src = '<img src="' . $image_url . '" alt="' . $short_caption . '" title="' . $short_caption . '" />';
734
  $image_output = $image_src;
@@ -763,7 +782,7 @@ class JR_InstagramSlider extends WP_Widget {
763
  $time = human_time_diff( $time );
764
  $output .= "<span class='jr-insta-time'>{$time} ago</span>\n";
765
  }
766
- if ( in_array( 'username', $args['description'] ) ) {
767
  $output .= "<span class='jr-insta-username'>by <a rel='nofollow' href='http://instagram.com/{$username}' target='_blank'>{$username}</a></span>\n";
768
  }
769
 
@@ -796,7 +815,7 @@ class JR_InstagramSlider extends WP_Widget {
796
  $output .= "<span class='jr-insta-time'>{$time} ago</span>\n";
797
  }
798
 
799
- if ( in_array( 'username', $args['description'] ) ) {
800
  $output .= "<span class='jr-insta-username'>by <a rel='nofollow' target='_blank' href='http://instagram.com/{$username}'>{$username}</a></span>\n";
801
  }
802
 
@@ -837,21 +856,36 @@ class JR_InstagramSlider extends WP_Widget {
837
  *
838
  * @return array of localy saved instagram data
839
  */
840
- private function instagram_data( $username, $cache_hours, $nr_images, $attachment ) {
841
 
842
- $opt_name = 'jr_insta_' . md5( $username );
 
 
 
 
 
 
 
 
 
 
843
  $instaData = get_transient( $opt_name );
844
  $user_opt = (array) get_option( $opt_name );
845
-
846
- if ( false === $instaData || $user_opt['username'] != $username || $user_opt['cache_hours'] != $cache_hours || $user_opt['nr_images'] != $nr_images || $user_opt['attachment'] != $attachment ) {
847
 
848
  $instaData = array();
849
- $user_opt['username'] = $username;
850
- $user_opt['cache_hours'] = $cache_hours;
851
- $user_opt['nr_images'] = $nr_images;
852
- $user_opt['attachment'] = $attachment;
853
-
854
- $response = wp_remote_get( 'http://instagram.com/' . trim( $username ), array( 'sslverify' => false, 'timeout' => 60 ) );
 
 
 
 
 
855
 
856
  if ( is_wp_error( $response ) ) {
857
 
@@ -883,13 +917,18 @@ class JR_InstagramSlider extends WP_Widget {
883
 
884
  if ( $results && is_array( $results ) ) {
885
 
886
- $userMedia = isset( $results['entry_data']['ProfilePage'][0]['user']['media']['nodes'] ) ? $results['entry_data']['ProfilePage'][0]['user']['media']['nodes'] : array();
 
 
 
 
 
887
 
888
- if ( empty( $userMedia ) ) {
889
  return __( 'No images found', 'jrinstaslider');
890
  }
891
 
892
- foreach ( $userMedia as $current => $result ) {
893
 
894
  if ( $result['is_video'] == true ) {
895
  $nr_images++;
@@ -900,15 +939,15 @@ class JR_InstagramSlider extends WP_Widget {
900
  break;
901
  }
902
 
903
- $meta_data = json_decode( wp_remote_retrieve_body( wp_remote_get( 'http://api.instagram.com/oembed?url=https://instagram.com/p/'. $result['code'], array( 'sslverify' => false ) ) ), true );
904
-
905
- $image_data['username'] = $username;
906
- $image_data['caption'] = $this->sanitize( $meta_data['title'] );
907
- $image_data['id'] = $result['id'];
908
- $image_data['link'] = 'https://instagram.com/p/'. $result['code'];
909
- $image_data['popularity'] = (int) ( $result['comments']['count'] ) + ( $result['likes']['count'] );
910
- $image_data['timestamp'] = (float) $result['date'];
911
- $image_data['url'] = $result['display_src'];
912
 
913
  // Image Sizes from instagram
914
  preg_match( '/([^\/]+$)/', $image_data['url'], $matches );
@@ -920,7 +959,7 @@ class JR_InstagramSlider extends WP_Widget {
920
  $image_data['url_thumbnail'] = str_replace( '_7.jpg', '_5.jpg', $image_data['url'] );
921
  }
922
 
923
- if ( !$attachment ) {
924
 
925
  $instaData[] = $image_data;
926
 
2
  /*
3
  Plugin Name: Instagram Slider Widget
4
  Plugin URI: http://jrwebstudio.com/instagram-slider/
5
+ Version: 1.3.0
6
  Description: Instagram Slider Widget is a responsive slider widget that shows 20 latest images from a public instagram user.
7
  Author: jetonr
8
  Author URI: http://jrwebstudio.com/
24
  *
25
  * @var string
26
  */
27
+ const VERSION = '1.3.0';
28
 
29
  /**
30
  * Initialize the plugin by registering widget and loading public scripts
136
  public function update( $new_instance, $instance ) {
137
 
138
  $instance['title'] = strip_tags( $new_instance['title'] );
139
+ $instance['search_for'] = $new_instance['search_for'];
140
  $instance['username'] = $new_instance['username'];
141
+ $instance['hashtag'] = $new_instance['hashtag'];
142
  $instance['source'] = $new_instance['source'];
143
  $instance['attachment'] = $new_instance['attachment'];
144
  $instance['template'] = $new_instance['template'];
153
  $instance['image_link_class'] = $new_instance['image_link_class'];
154
  $instance['controls'] = $new_instance['controls'];
155
  $instance['animation'] = $new_instance['animation'];
156
+ $instance['caption_words'] = $new_instance['caption_words'];
157
  $instance['slidespeed'] = $new_instance['slidespeed'];
158
  $instance['description'] = $new_instance['description'];
159
 
170
 
171
  $defaults = array(
172
  'title' => __('Instagram Slider', 'jrinstaslider'),
173
+ 'search_for' => 'username',
174
  'username' => '',
175
+ 'hashtag' => '',
176
  'source' => 'instagram',
177
  'attachment' => 1,
178
  'template' => 'slider',
182
  'images_number' => 5,
183
  'columns' => 4,
184
  'refresh_hour' => 5,
185
+ 'image_size' => 'large',
186
  'image_link_rel' => '',
187
  'image_link_class' => '',
188
  'controls' => 'prev_next',
189
  'animation' => 'slide',
190
+ 'caption_words' => 100,
191
  'slidespeed' => 7000,
192
  'description' => array( 'username', 'time','caption' )
193
  );
197
  ?>
198
  <div class="jr-container">
199
  <p>
200
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><strong><?php _e('Title:', 'jrinstaslider'); ?></strong></label>
201
  <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" />
202
  </p>
203
  <p>
204
+ <strong><?php _e( 'Search Instagram for:', 'jrinstaslider' ); ?></strong>
205
+ <span class="jr-search-for-container"><label class="jr-seach-for"><input type="radio" id="<?php echo $this->get_field_id( 'search_for' ); ?>" name="<?php echo $this->get_field_name( 'search_for' ); ?>" value="username" <?php checked( 'username', $instance['search_for'] ); ?> /> <?php _e( 'Username:', 'jrinstaslider' ); ?></label> <input id="<?php echo $this->get_field_id( 'username' ); ?>" class="inline-field-text" name="<?php echo $this->get_field_name( 'username' ); ?>" value="<?php echo $instance['username']; ?>" /></span>
206
+ <span class="jr-search-for-container"><label class="jr-seach-for"><input type="radio" id="<?php echo $this->get_field_id( 'search_for' ); ?>" name="<?php echo $this->get_field_name( 'search_for' ); ?>" value="hashtag" <?php checked( 'hashtag', $instance['search_for'] ); ?> /> <?php _e( 'Hashtag:', 'jrinstaslider' ); ?></label> <input id="<?php echo $this->get_field_id( 'hashtag' ); ?>" class="inline-field-text" name="<?php echo $this->get_field_name( 'hashtag' ); ?>" value="<?php echo $instance['hashtag']; ?>" /> <small><?php _e('without # sign', 'jrinstaslider'); ?></small></span>
207
  </p>
208
+ <p class="<?php if ( 'username' != $instance['search_for'] ) echo 'hidden'; ?>">
209
+ <strong><?php _e( 'Source:', 'jrinstaslider' ); ?></strong><br>
210
  <label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'source' ); ?>" name="<?php echo $this->get_field_name( 'source' ); ?>" value="instagram" <?php checked( 'instagram', $instance['source'] ); ?> /> <?php _e( 'Instagram', 'jrinstaslider' ); ?></label>
211
  <label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'source' ); ?>" name="<?php echo $this->get_field_name( 'source' ); ?>" value="media_library" <?php checked( 'media_library', $instance['source'] ); ?> /> <?php _e( 'WP Media Library', 'jrinstaslider' ); ?></label>
212
  <?php
213
+
214
  $saved_images = 0;
215
  $username = '';
216
 
223
  $insta_option_class = 'hide-instagram';
224
  }
225
 
 
226
  if ( isset( $instance['username'] ) && ( !empty( $instance['username'] ) ) ) {
227
  $username = $instance['username'];
228
  $savedinsta_args = array(
252
  echo '<span class="jr-description jr-instagram-option '.$insta_option_class.'"><strong>Instagram</strong> can display up to <strong>24</strong> images for <strong>'. $username .'</strong>!<br> This option will check for new images on Instagram!</span>';
253
  ?>
254
  </p>
255
+ <p class="<?php if ( 'instagram' != $instance['source'] || 'username' != $instance['search_for'] ) echo 'hidden'; ?>">
256
+ <strong><label for="<?php echo $this->get_field_id( 'attachment' ); ?>"><?php _e( 'Save and Display Images from Media Library:', 'jrinstaslider' ); ?></label></strong>
257
  <input class="widefat" id="<?php echo $this->get_field_id( 'attachment' ); ?>" name="<?php echo $this->get_field_name( 'attachment' ); ?>" type="checkbox" value="1" <?php checked( '1', $instance['attachment'] ); ?> />
258
  <br><span class="jr-description"><?php _e( 'It is recommended you check the field above because images displayed directly from Instagram server will affect your site loading time!', 'jrinstaslider') ?></span>
259
  </p>
260
  <p>
261
+ <label for="<?php echo $this->get_field_id( 'images_number' ); ?>"><strong><?php _e( 'Number of images to show:', 'jrinstaslider' ); ?></strong>
262
  <input class="small-text" id="<?php echo $this->get_field_id( 'images_number' ); ?>" name="<?php echo $this->get_field_name( 'images_number' ); ?>" value="<?php echo $instance['images_number']; ?>" />
263
  </label>
264
  </p>
265
  <p class="<?php if ( 'instagram' != $instance['source'] ) echo 'hidden'; ?>">
266
+ <label for="<?php echo $this->get_field_id( 'refresh_hour' ); ?>"><strong><?php _e( 'Check for new images every:', 'jrinstaslider' ); ?></strong>
267
  <input class="small-text" id="<?php echo $this->get_field_id( 'refresh_hour' ); ?>" name="<?php echo $this->get_field_name( 'refresh_hour' ); ?>" value="<?php echo $instance['refresh_hour']; ?>" />
268
  <span><?php _e('hours', 'jrinstaslider'); ?></span>
269
  </label>
270
  </p>
271
  <?php
272
  $user_opt = get_option( 'jr_insta_'. md5( $instance['username'] ) );
273
+ if ( isset( $user_opt['deleted_images'] ) && ( !empty( $user_opt['deleted_images'] ) && ( $instance['source'] == 'instagram' ) && ( $instance['attachment'] ) && ( 'username' == $instance['search_for'] ) ) ) {
274
  $deleted_count = count( $user_opt['deleted_images'] );
275
  echo '<div class="blocked-wrap">';
276
  wp_nonce_field( 'jr_unblock_instagram_image', 'unblock_images_nonce' );
288
  }
289
  ?>
290
  <p>
291
+ <label for="<?php echo $this->get_field_id( 'template' ); ?>"><strong><?php _e( 'Template', 'jrinstaslider' ); ?></strong>
292
  <select class="widefat" name="<?php echo $this->get_field_name( 'template' ); ?>" id="<?php echo $this->get_field_id( 'template' ); ?>">
293
  <option value="slider" <?php echo ($instance['template'] == 'slider') ? ' selected="selected"' : ''; ?>><?php _e( 'Slider - Normal', 'jrinstaslider' ); ?></option>
294
  <option value="slider-overlay" <?php echo ($instance['template'] == 'slider-overlay') ? ' selected="selected"' : ''; ?>><?php _e( 'Slider - Overlay Text', 'jrinstaslider' ); ?></option>
298
  </label>
299
  </p>
300
  <p class="<?php if ( 'thumbs' != $instance['template'] && 'thumbs-no-border' != $instance['template'] ) echo 'hidden'; ?>">
301
+ <label for="<?php echo $this->get_field_id( 'columns' ); ?>"><strong><?php _e( 'Number of Columns:', 'jrinstaslider' ); ?></strong>
302
  <input class="small-text" id="<?php echo $this->get_field_id( 'columns' ); ?>" name="<?php echo $this->get_field_name( 'columns' ); ?>" value="<?php echo $instance['columns']; ?>" />
303
  <span class='jr-description'><?php _e('max is 10 ( only for thumbnails template )', 'jrinstaslider'); ?></span>
304
  </label>
313
  }
314
  */
315
  ?>
316
+ <label for="<?php echo $this->get_field_id( 'image_size' ); ?>"><strong><?php _e( 'Image size', 'jrinstaslider' ); ?></strong></label>
317
  <select class="widefat" id="<?php echo $this->get_field_id( 'image_size' ); ?>" name="<?php echo $this->get_field_name( 'image_size' ); ?>">
318
  <option value=""><?php _e('Select Image Size', 'jrinstaslider') ?></option>
319
  <?php
329
  </select>
330
  </p>
331
  <p>
332
+ <label for="<?php echo $this->get_field_id( 'orderby' ); ?>"><strong><?php _e( 'Order by', 'jrinstaslider' ); ?></strong>
333
  <select class="widefat" name="<?php echo $this->get_field_name( 'orderby' ); ?>" id="<?php echo $this->get_field_id( 'orderby' ); ?>">
334
  <option value="date-ASC" <?php selected( $instance['orderby'], 'date-ASC', true); ?>><?php _e( 'Date - Ascending', 'jrinstaslider' ); ?></option>
335
  <option value="date-DESC" <?php selected( $instance['orderby'], 'date-DESC', true); ?>><?php _e( 'Date - Descending', 'jrinstaslider' ); ?></option>
340
  </label>
341
  </p>
342
  <p>
343
+ <label for="<?php echo $this->get_field_id( 'images_link' ); ?>"><strong><?php _e( 'Link to', 'jrinstaslider' ); ?></strong>
344
  <select class="widefat" name="<?php echo $this->get_field_name( 'images_link' ); ?>" id="<?php echo $this->get_field_id( 'images_link' ); ?>">
345
  <option value="image_url" <?php selected( $instance['images_link'], 'image_url', true); ?>><?php _e( 'Instagram Image', 'jrinstaslider' ); ?></option>
346
+ <option class="<?php if ( 'hashtag' == $instance['search_for'] ) echo 'hidden'; ?>" value="user_url" <?php selected( $instance['images_link'], 'user_url', true); ?>><?php _e( 'Instagram Profile', 'jrinstaslider' ); ?></option>
347
+ <option class="<?php if ( ( !$instance['attachment'] && 'instagram' == $instance['source'] ) || 'hashtag' == $instance['search_for'] ) echo 'hidden'; ?>" value="local_image_url" <?php selected( $instance['images_link'], 'local_image_url', true); ?>><?php _e( 'Locally Saved Image', 'jrinstaslider' ); ?></option>
348
+ <option class="<?php if ( ( !$instance['attachment'] && 'instagram' == $instance['source'] ) || 'hashtag' == $instance['search_for'] ) echo 'hidden'; ?>" value="attachment" <?php selected( $instance['images_link'], 'attachment', true); ?>><?php _e( 'Attachment Page', 'jrinstaslider' ); ?></option>
 
 
349
  <option value="custom_url" <?php selected( $instance['images_link'], 'custom_url', true ); ?>><?php _e( 'Custom Link', 'jrinstaslider' ); ?></option>
350
  <option value="none" <?php selected( $instance['images_link'], 'none', true); ?>><?php _e( 'None', 'jrinstaslider' ); ?></option>
351
  </select>
396
  <label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'animation' ); ?>" name="<?php echo $this->get_field_name( 'animation' ); ?>" value="slide" <?php checked( 'slide', $instance['animation'] ); ?> /> <?php _e( 'Slide', 'jrinstaslider' ); ?></label>
397
  <label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'animation' ); ?>" name="<?php echo $this->get_field_name( 'animation' ); ?>" value="fade" <?php checked( 'fade', $instance['animation'] ); ?> /> <?php _e( 'Fade', 'jrinstaslider' ); ?></label>
398
  </p>
399
+ <p>
400
+ <label for="<?php echo $this->get_field_id( 'caption_words' ); ?>"><?php _e( 'Number of words in caption:', 'jrinstaslider' ); ?>
401
+ <input class="small-text" id="<?php echo $this->get_field_id( 'caption_words' ); ?>" name="<?php echo $this->get_field_name( 'caption_words' ); ?>" value="<?php echo $instance['caption_words']; ?>" />
402
+ </label>
403
+ </p>
404
  <p>
405
  <label for="<?php echo $this->get_field_id( 'slidespeed' ); ?>"><?php _e( 'Slide Speed:', 'jrinstaslider' ); ?>
406
  <input class="small-text" id="<?php echo $this->get_field_id( 'slidespeed' ); ?>" name="<?php echo $this->get_field_name( 'slidespeed' ); ?>" value="<?php echo $instance['slidespeed']; ?>" />
411
  <p>
412
  <label for="<?php echo $this->get_field_id('description'); ?>"><?php _e( 'Slider Text Description:', 'jrinstaslider' ); ?></label>
413
  <select size=3 class='widefat' id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>[]" multiple="multiple">
414
+ <option class="<?php if ( 'hashtag' == $instance['search_for'] ) echo 'hidden'; ?>" value='username' <?php $this->selected( $instance['description'], 'username' ); ?>><?php _e( 'Username', 'jrinstaslider'); ?></option>
415
  <option value='time'<?php $this->selected( $instance['description'], 'time' ); ?>><?php _e( 'Time', 'jrinstaslider'); ?></option>
416
  <option value='caption'<?php $this->selected( $instance['description'], 'caption' ); ?>><?php _e( 'Caption', 'jrinstaslider'); ?></option>
417
  </select>
480
  * @return string
481
  */
482
  private function display_images( $args ) {
483
+
484
  $username = isset( $args['username'] ) && !empty( $args['username'] ) ? $args['username'] : false;
485
+ $hashtag = isset( $args['hashtag'] ) && !empty( $args['hashtag'] ) ? $args['hashtag'] : false;
486
  $source = isset( $args['source'] ) && !empty( $args['source'] ) ? $args['source'] : 'instagram';
487
  $attachment = isset( $args['attachment'] ) ? true : false;
488
  $template = isset( $args['template'] ) ? $args['template'] : 'slider';
492
  $images_number = isset( $args['images_number'] ) ? absint( $args['images_number'] ) : 5;
493
  $columns = isset( $args['columns'] ) ? absint( $args['columns'] ) : 4;
494
  $refresh_hour = isset( $args['refresh_hour'] ) ? absint( $args['refresh_hour'] ) : 5;
495
+ $image_size = isset( $args['image_size'] ) ? $args['image_size'] : 'large';
496
  $image_link_rel = isset( $args['image_link_rel'] ) ? $args['image_link_rel'] : '';
497
  $image_link_class = isset( $args['image_link_class'] ) ? $args['image_link_class'] : '';
498
  $controls = isset( $args['controls'] ) ? $args['controls'] : 'prev_next';
499
  $animation = isset( $args['animation'] ) ? $args['animation'] : 'slide';
500
+ $caption_words = isset( $args['caption_words'] ) ? $args['caption_words'] : 100;
501
  $slidespeed = isset( $args['slidespeed'] ) ? $args['slidespeed'] : 7000;
502
  $description = isset( $args['description'] ) ? $args['description'] : array();
503
  $widget_id = isset( $args['widget_id'] ) ? $args['widget_id'] : preg_replace( '/[^0-9]/', '', $this->id );
504
 
 
 
 
 
505
  if ( !empty( $description ) && !is_array( $description ) ) {
506
  $description = explode( ',', $description );
507
  }
508
 
509
+ if ( isset ( $args['search_for'] ) && $args['search_for'] == 'hashtag' ) {
510
+ $search = 'hashtag';
511
+ $search_for['hashtag'] = $hashtag;
512
+ } else {
513
+ $search = 'user';
514
+ $search_for['username'] = $username;
515
+ }
516
+
517
  if ( $source == 'instagram' && $refresh_hour == 0 ) {
518
  $refresh_hour = 5;
519
  }
520
 
521
  $template_args = array(
522
+ 'search_for' => $search,
523
+ 'source' => $source,
524
+ 'attachment' => $attachment,
525
+ 'image_size' => $image_size,
526
+ 'link_rel' => $image_link_rel,
527
+ 'link_class' => $image_link_class,
528
+ 'caption_words' => $caption_words
529
  );
530
 
531
  $images_div_class = 'jr-insta-thumb';
585
  $images_div = "<div class='{$images_div_class}'>\n";
586
  $images_ul = "<ul class='no-bullet {$ul_class}'>\n";
587
 
588
+ $output = __( 'No images found! <br> Try some other hashtag or username', 'jrinstaslider' );
589
 
590
+ if ( ( $search == 'user' && $attachment && $source == 'instagram' ) || ( $search == 'user' && $source == 'media_library') ) {
591
 
592
  $query_args = array(
593
  'post_type' => 'attachment',
620
 
621
  } else {
622
 
623
+ $attachment_ids = $this->instagram_data( $search_for, $refresh_hour, $images_number, true );
624
 
625
  if ( is_array( $attachment_ids ) && !empty( $attachment_ids ) ) {
626
  $query_args['post__in'] = $attachment_ids;
627
  } else {
628
  if ( is_array( $attachment_ids ) ) {
629
+ return __( 'No images found! <br> Try some other hashtag or username!', 'jrinstaslider' );
630
  } else {
631
  return $attachment_ids;
632
  }
666
 
667
  } else {
668
 
669
+ $images_data = $this->instagram_data( $search_for, $refresh_hour, $images_number, false );
670
 
671
  if ( is_array( $images_data ) && !empty( $images_data ) ) {
672
 
704
  $template_args['image'] = $image_data['url'];
705
  }
706
 
707
+ $template_args['caption'] = $image_data['caption'];
708
+ $template_args['timestamp'] = $image_data['timestamp'];
709
+ $template_args['username'] = $image_data['username'];
710
 
711
  $output .= $this->get_template( $template, $template_args );
712
  }
731
 
732
  $link_to = isset( $args['link_to'] ) ? $args['link_to'] : false;
733
 
734
+ if ( ( $args['search_for'] == 'user' && $args['attachment'] !== true && $args['source'] == 'instagram' ) || $args['search_for'] == 'hashtag' ) {
735
  $caption = $args['caption'];
736
  $time = $args['timestamp'];
737
  $username = $args['username'];
747
 
748
  $short_caption = wp_trim_words( $caption, 10 );
749
  $short_caption = preg_replace("/[^A-Za-z0-9?! ]/","", $short_caption);
750
+ $caption = wp_trim_words( $caption, $args['caption_words'], $more = null );
751
 
752
  $image_src = '<img src="' . $image_url . '" alt="' . $short_caption . '" title="' . $short_caption . '" />';
753
  $image_output = $image_src;
782
  $time = human_time_diff( $time );
783
  $output .= "<span class='jr-insta-time'>{$time} ago</span>\n";
784
  }
785
+ if ( in_array( 'username', $args['description'] ) && $username ) {
786
  $output .= "<span class='jr-insta-username'>by <a rel='nofollow' href='http://instagram.com/{$username}' target='_blank'>{$username}</a></span>\n";
787
  }
788
 
815
  $output .= "<span class='jr-insta-time'>{$time} ago</span>\n";
816
  }
817
 
818
+ if ( in_array( 'username', $args['description'] ) && $username ) {
819
  $output .= "<span class='jr-insta-username'>by <a rel='nofollow' target='_blank' href='http://instagram.com/{$username}'>{$username}</a></span>\n";
820
  }
821
 
856
  *
857
  * @return array of localy saved instagram data
858
  */
859
+ private function instagram_data( $search_for, $cache_hours, $nr_images, $attachment ) {
860
 
861
+ if ( isset( $search_for['username'] ) && !empty( $search_for['username'] ) ) {
862
+ $search = 'user';
863
+ $search_string = $search_for['username'];
864
+ } elseif ( isset( $search_for['hashtag'] ) && !empty( $search_for['hashtag'] ) ) {
865
+ $search = 'hashtag';
866
+ $search_string = $search_for['hashtag'];
867
+ } else {
868
+ return __( 'Nothing to search for', 'jrinstaslider');
869
+ }
870
+
871
+ $opt_name = 'jr_insta_' . md5( $search . '_' . $search_string );
872
  $instaData = get_transient( $opt_name );
873
  $user_opt = (array) get_option( $opt_name );
874
+
875
+ if ( false === $instaData || $user_opt['search_string'] != $search_string || $user_opt['search'] != $search || $user_opt['cache_hours'] != $cache_hours || $user_opt['nr_images'] != $nr_images || $user_opt['attachment'] != $attachment ) {
876
 
877
  $instaData = array();
878
+ $user_opt['search'] = $search;
879
+ $user_opt['search_string'] = $search_string;
880
+ $user_opt['cache_hours'] = $cache_hours;
881
+ $user_opt['nr_images'] = $nr_images;
882
+ $user_opt['attachment'] = $attachment;
883
+
884
+ if ( 'user' == $search ) {
885
+ $response = wp_remote_get( 'http://instagram.com/' . trim( $search_string ), array( 'sslverify' => false, 'timeout' => 60 ) );
886
+ } else {
887
+ $response = wp_remote_get( 'http://instagram.com/explore/tags/' . trim( $search_string ), array( 'sslverify' => false, 'timeout' => 60 ) );
888
+ }
889
 
890
  if ( is_wp_error( $response ) ) {
891
 
917
 
918
  if ( $results && is_array( $results ) ) {
919
 
920
+ if ( 'user' == $search ) {
921
+ $entry_data = isset( $results['entry_data']['ProfilePage'][0]['user']['media']['nodes'] ) ? $results['entry_data']['ProfilePage'][0]['user']['media']['nodes'] : array();
922
+ } else {
923
+ $entry_data = isset( $results['entry_data']['TagPage'][0]['tag']['media']['nodes'] ) ? $results['entry_data']['TagPage'][0]['tag']['media']['nodes'] : array();
924
+ }
925
+
926
 
927
+ if ( empty( $entry_data ) ) {
928
  return __( 'No images found', 'jrinstaslider');
929
  }
930
 
931
+ foreach ( $entry_data as $current => $result ) {
932
 
933
  if ( $result['is_video'] == true ) {
934
  $nr_images++;
939
  break;
940
  }
941
 
942
+ $image_data['code'] = $result['code'];
943
+ $image_data['username'] = 'user' == $search ? $search_string : false;
944
+ $image_data['user_id'] = $result['owner']['id'];
945
+ $image_data['caption'] = $this->sanitize( $result['caption'] );
946
+ $image_data['id'] = $result['id'];
947
+ $image_data['link'] = 'https://instagram.com/p/'. $result['code'];
948
+ $image_data['popularity'] = (int) ( $result['comments']['count'] ) + ( $result['likes']['count'] );
949
+ $image_data['timestamp'] = (float) $result['date'];
950
+ $image_data['url'] = $result['display_src'];
951
 
952
  // Image Sizes from instagram
953
  preg_match( '/([^\/]+$)/', $image_data['url'], $matches );
959
  $image_data['url_thumbnail'] = str_replace( '_7.jpg', '_5.jpg', $image_data['url'] );
960
  }
961
 
962
+ if ( ( $search == 'hashtag' ) || ( $search == 'user' && !$attachment ) ) {
963
 
964
  $instaData[] = $image_data;
965
 
readme.txt CHANGED
@@ -43,6 +43,12 @@ I will try to respond on wordpress.org asap but for faster reposnse use the link
43
  3. Backend Configuration
44
 
45
  == Changelog ==
 
 
 
 
 
 
46
  = 1.2.3 =
47
  * Added Links for Instagram Hashtags
48
  * Updtated flexislider to 2.5.0
43
  3. Backend Configuration
44
 
45
  == Changelog ==
46
+ = 1.3.0 =
47
+ * Added Option to search for hashtags
48
+ * Added Limit for number of words to appear in caption
49
+ * Fixed 500 server error that accured when loading 15+ images
50
+ * Fixed css for some themes
51
+
52
  = 1.2.3 =
53
  * Added Links for Instagram Hashtags
54
  * Updtated flexislider to 2.5.0