Instagram Gallery - Version 1.2.4

Version Description

  • IE images issue fixed
Download this release

Release Info

Developer buntisoft
Plugin Icon 128x128 Instagram Gallery
Version 1.2.4
Comparing to
See all releases

Code changes from version 1.1.3 to 1.2.4

app/ig-spider.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Instagram Spider
5
+ * @author Karan Singh
6
+ * @version 1.1.1
7
+ * @description get items.
8
+ */
9
+ class InstagramSpider
10
+ {
11
+
12
+ protected $instagram;
13
+
14
+ public $messages;
15
+
16
+ public function __construct()
17
+ {
18
+ $this->instagram = 'https://www.instagram.com/';
19
+ $this->messages = array();
20
+ }
21
+
22
+ /**
23
+ * takes username and return items list array
24
+ *
25
+ * @param string $username
26
+ * @return array
27
+ */
28
+ function getUserItems($username = '')
29
+ {
30
+ $username = (string) $username;
31
+ if (empty($username)) {
32
+ $this->messages[] = 'Please provide a valid username';
33
+ return;
34
+ }
35
+
36
+ $inURL = $this->instagram . $username . '/media/';
37
+ $instaRes = $this->ig_spider($inURL);
38
+ $instaRes = @json_decode($instaRes);
39
+
40
+ $items = array();
41
+ if (isset($instaRes->items)) {
42
+ $instaRes = $instaRes->items;
43
+
44
+ if (! empty($instaRes) && is_array($instaRes)) {
45
+ foreach ($instaRes as $res) {
46
+ $items[] = array('img_standard' => $res->images->standard_resolution->url,
47
+ 'img_low' => $res->images->low_resolution->url
48
+ );
49
+ }
50
+ }
51
+ }
52
+ return $items;
53
+ }
54
+
55
+ /**
56
+ * takes #Tag name and return items list array
57
+ *
58
+ * @param string $tag
59
+ * @return array
60
+ */
61
+ function getTagItems($tag = '')
62
+ {
63
+ $tag = (string) $tag;
64
+ if (empty($tag)) {
65
+ $this->messages[] = 'Please provide a valid # tag';
66
+ return;
67
+ }
68
+ $inURL = $this->instagram . 'explore/tags/' . $tag . '/?__a=1';
69
+ $instaRes = $this->ig_spider($inURL);
70
+ $instaRes = json_decode($instaRes);
71
+ $items = array();
72
+ if (isset($instaRes->tag->media->nodes)) {
73
+ $instaRes = $instaRes->tag->media->nodes;
74
+
75
+ if (! empty($instaRes) && is_array($instaRes)) {
76
+ foreach ($instaRes as $res) {
77
+ $items[] = array('img_standard' => $res->display_src,
78
+ 'img_low' => $res->thumbnail_src
79
+ );
80
+ }
81
+ }
82
+ }
83
+
84
+ return $items;
85
+ }
86
+
87
+ /**
88
+ * takes URL string and return URL content
89
+ *
90
+ * @param string $url
91
+ * @return string
92
+ */
93
+ protected function ig_spider($url = '')
94
+ {
95
+ if (empty($url) || (! filter_var($url, FILTER_VALIDATE_URL))) {
96
+ $this->messages[] = 'Please provide a Valid URL';
97
+ return;
98
+ }
99
+ $instaItems = '';
100
+ if (function_exists('curl_version')) {
101
+ $ch = curl_init();
102
+ curl_setopt($ch, CURLOPT_URL, $url);
103
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
104
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
105
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
106
+ $contents = curl_exec($ch);
107
+ if (curl_error($ch)) {
108
+ $this->messages[] = 'error: ' . curl_error($ch);
109
+ }
110
+ curl_close($ch);
111
+ $instaItems = $contents;
112
+ } else {
113
+ if (ini_get('allow_url_fopen')) {
114
+ $instaItems = @file_get_contents($url);
115
+ } else {
116
+ $this->messages[] = 'Your server does\'t have enabled the required extensions/functions.';
117
+ }
118
+ }
119
+ return $instaItems;
120
+ }
121
+ // return messages array
122
+ public function getMessages()
123
+ {
124
+ return $this->messages;
125
+ }
126
+ }
app/views/edit.php ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (! defined('ABSPATH')) {
3
+ die();
4
+ }
5
+ $InstaGalleryItem = null;
6
+ if (isset($_GET['ig_item']) && ! empty( $_GET['ig_item']) ) {
7
+ $ig_item_id = (int) $_GET['ig_item'];
8
+ $InstaGalleryItems = get_option('insta_gallery_items');
9
+ if (isset($InstaGalleryItems[$ig_item_id])) {
10
+ $InstaGalleryItem = $InstaGalleryItems[$ig_item_id];
11
+ $InstaGalleryItem['ig_item_id'] = $ig_item_id;
12
+ }
13
+ }
14
+
15
+ $active_username = true;
16
+ $active_tag = false;
17
+ if (isset($InstaGalleryItem['ig_select_from'])) {
18
+ if ($InstaGalleryItem['ig_select_from'] != 'username') {
19
+ $active_username = false;
20
+ $active_tag = true;
21
+ }
22
+ }
23
+ $active_gallery = true;
24
+ $active_slider = false;
25
+ if (isset($InstaGalleryItem['ig_display_type'])) {
26
+ if ($InstaGalleryItem['ig_display_type'] != 'gallery') {
27
+ $active_gallery = false;
28
+ $active_slider = true;
29
+ }
30
+ }
31
+
32
+ ?>
33
+ <p>
34
+ <a href="<?php echo INSGALLERY_URL_ADMIN_PAGE; ?>" title="View Galleries List" class="ig-btn"><span
35
+ class="dashicons dashicons-arrow-left-alt"></span>Back to List</a>
36
+ </p>
37
+ <form method="post" id="ig-form-update" action="<?php if(empty($InstaGalleryItem)) echo INSGALLERY_URL_ADMIN_PAGE; ?>">
38
+ <table class="form-table ig-table-edit">
39
+ <tbody>
40
+ <tr>
41
+ <th scope="row">Display Instagram Gallery from:</th>
42
+ <td>
43
+ <ul class="ig-list-buttons">
44
+ <li>
45
+ <input type="radio" id="ig_select_from-username" name="ig_select_from" value="username"
46
+ <?php if($active_username) echo 'checked';?> /><label for="ig_select_from-username">User Name</label>
47
+ <div class="check"></div>
48
+ </li>
49
+ <li>
50
+ <input type="radio" id="ig_select_from-tag" name="ig_select_from" value="tag"
51
+ <?php if($active_tag) echo 'checked';?> /> <label for="ig_select_from-tag"># Tag</label>
52
+ <div class="check"></div>
53
+ </li>
54
+ </ul> <span class="description"> (Please select option to show pics from Instagram Username OR # Tag.)</span>
55
+
56
+ </td>
57
+ </tr>
58
+ <tr id="ig-select-username-wrap" class="ig-tab-content-row <?php if($active_username) echo 'active';?>">
59
+ <td colspan="100%">
60
+ <table>
61
+ <tr>
62
+ <th scope="row">Instagram User Name:</th>
63
+ <td><input name="insta_user" type="text" placeholder="MyUsername"
64
+ value="<?php if(!empty($InstaGalleryItem['insta_user'])){echo $InstaGalleryItem['insta_user']; }?>" /> <span
65
+ class="description">e.g. https://www.instagram.com/<strong style="font-size: 120%; color: #e23565;">MyUsername</strong>/
66
+ </span>
67
+ <p class="ig-generate-msgs">Please enter Instagram User Name.</p></td>
68
+ </tr>
69
+ </table>
70
+ </td>
71
+ </tr>
72
+ <tr id="ig-select-tag-wrap" class="ig-tab-content-row <?php if($active_tag) echo 'active';?>">
73
+ <td colspan="100%">
74
+ <table>
75
+ <tr>
76
+ <th scope="row">Instagram # Tag:</th>
77
+ <td><input name="insta_tag" type="text" placeholder="beautiful"
78
+ value="<?php if(!empty($InstaGalleryItem['insta_tag'])){echo $InstaGalleryItem['insta_tag']; }?>" /> <span
79
+ class="description">e.g. https://www.instagram.com/explore/tags/<strong style="font-size: 120%; color: #e23565;">beautiful</strong>/
80
+ </span>
81
+ <p class="ig-generate-msgs">Please enter Instagram # Tag.</p></td>
82
+ </td>
83
+ </tr>
84
+ </table>
85
+ </td>
86
+ </tr>
87
+ <tr>
88
+ <th scope="row">Pictures Limit:</th>
89
+ <td><input name="insta_limit" type="number" min="1" max="20"
90
+ value="<?php if(!empty($InstaGalleryItem['insta_limit'])){echo $InstaGalleryItem['insta_limit']; } else {echo '12'; }?>" />
91
+ <span class="description">number of pics to display on page. (max: 20)</span></td>
92
+ </tr>
93
+ <tr>
94
+ <th scope="row">Show As:</th>
95
+ <td>
96
+ <ul class="ig-list-buttons">
97
+ <li>
98
+ <input type="radio" id="ig_display_type-gallery" name="ig_display_type" value="gallery"
99
+ <?php if($active_gallery) echo 'checked';?> /><label for="ig_display_type-gallery">Gallery</label>
100
+ <div class="check"></div>
101
+ </li>
102
+ <li>
103
+ <input type="radio" id="ig_display_type-slider" name="ig_display_type" value="slider"
104
+ <?php if($active_slider) echo 'checked';?> /><label for="ig_display_type-slider"> Slider</label>
105
+ <div class="check"></div>
106
+ </li>
107
+ </ul>
108
+ </td>
109
+ </tr>
110
+ <tr id="ig-section-as-galllery" class="ig-tab-content-row <?php if($active_gallery) echo 'active';?>">
111
+ <td colspan="100%">
112
+ <p>Pictures will be displayed as Grid and we can popup gallery by clicking them. </p>
113
+ <table>
114
+ <tr>
115
+ <th scope="row">No. of Pics Columns:</th>
116
+ <td><input name="insta_gal-cols" type="number" min="1" max="20"
117
+ value="<?php if(!empty($InstaGalleryItem['insta_gal-cols'])){echo $InstaGalleryItem['insta_gal-cols']; } else {echo 3;}?>" />
118
+ <span class="description">number of pics in a row. </span></td>
119
+ <td rowspan="3"><img src="<?php echo INSGALLERY_URL; ?>/assests/media/demo-gallery.jpg" alt="demo gallery"
120
+ width="500" /></td>
121
+ </tr>
122
+ <tr>
123
+ <th scope="row">Popup image on click:</th>
124
+ <td><input name="insta_gal-popup" type="checkbox" value="1"
125
+ <?php echo (isset($InstaGalleryItem) && empty($InstaGalleryItem['insta_gal-popup'])) ? '' : 'checked'; ?> /> <span
126
+ class="description">show popup gallery by clicking on image <br />( uncheck this if it conflicts with other
127
+ plugins)
128
+ </span></td>
129
+ </tr>
130
+ <tr>
131
+ <th scope="row">Image hover effect:</th>
132
+ <td><input name="insta_gal-hover" type="checkbox" value="1"
133
+ <?php echo (isset($InstaGalleryItem) && empty($InstaGalleryItem['insta_gal-hover'])) ? '' : 'checked'; ?> /> <span
134
+ class="description">mouseover animation effect on image </span></td>
135
+ </tr>
136
+ <tr>
137
+ <th scope="row">Space between images:</th>
138
+ <td><input name="insta_gal-spacing" type="checkbox" value="1"
139
+ <?php echo (isset($InstaGalleryItem) && empty($InstaGalleryItem['insta_gal-spacing'])) ? '' : 'checked'; ?> /> <span
140
+ class="description">add blank space between images </span></td>
141
+ </tr>
142
+ </table>
143
+ </td>
144
+ </tr>
145
+ <tr id="ig-section-as-slider" class="ig-tab-content-row <?php if($active_slider) echo 'active';?>">
146
+ <td colspan="100%">
147
+ <p>Pictures will be displayed as Slider. for better display pictures should be same size.</p>
148
+ <table>
149
+ <tr>
150
+ <th scope="row">Slide effect:</th>
151
+ <td><select name="insta_sli-effect">
152
+ <option value="fade">fade</option>
153
+ <option value="slide"
154
+ <?php echo (isset($InstaGalleryItem['insta_sli-effect']) && ($InstaGalleryItem['insta_sli-effect']=='slide')) ? 'selected' : ''; ?>>slide</option>
155
+ </select> <span class="description">sliding effect/animation. </span></td>
156
+ <td rowspan="5"><img src="<?php echo INSGALLERY_URL; ?>/assests/media/demo-slider.jpg" alt="demo slider"
157
+ width="500" /></td>
158
+ </tr>
159
+ <tr>
160
+ <th scope="row">Slide timeout:</th>
161
+ <td><input name="insta_sli-timeout" type="number" min="100" max="20000"
162
+ value="<?php if(!empty($InstaGalleryItem['insta_sli-timeout'])){echo $InstaGalleryItem['insta_sli-timeout']; } else {echo 5000;}?>" />
163
+ <span class="description">slide duration in seconds. </span></td>
164
+ </tr>
165
+ <tr>
166
+ <th scope="row">Navigation arrows:</th>
167
+ <td><input name="insta_sli-navarrows" type="checkbox" value="1"
168
+ <?php echo (isset($InstaGalleryItem) && empty($InstaGalleryItem['insta_sli-navarrows'])) ? '' : 'checked'; ?> />
169
+ <span class="description">show prev-next navigation arrows. </span></td>
170
+ </tr>
171
+ <tr>
172
+ <th scope="row">Dotted navigation:</th>
173
+ <td><input name="insta_sli-dots" type="checkbox" value="1"
174
+ <?php echo (isset($InstaGalleryItem) && empty($InstaGalleryItem['insta_sli-dots'])) ? '' : 'checked'; ?> /> <span
175
+ class="description">show dotted navigation buttons. </span></td>
176
+ </tr>
177
+ <tr>
178
+ <th scope="row">Scrollbar:</th>
179
+ <td><input name="insta_sli-scroll" type="checkbox" value="1"
180
+ <?php echo (isset($InstaGalleryItem) && empty($InstaGalleryItem['insta_sli-scroll'])) ? '' : 'checked'; ?> /> <span
181
+ class="description">show scrollbar on slider bottom. </span></td>
182
+ </tr>
183
+ </table>
184
+ </td>
185
+ </tr>
186
+ </tbody>
187
+ </table>
188
+ <div>
189
+ <button class="button-primary ig-add-update" type="submit">
190
+ <span class="dashicons dashicons-plus"></span> Update / Add
191
+ </button>
192
+ <p class="description">update info here and copy/paste generated shortcode in your post/pages.</p>
193
+ </div>
194
+ <input type="hidden" name="ig-form-update" value="true" />
195
+ <?php if(!empty($InstaGalleryItem['ig_item_id'])) {?>
196
+ <input type="hidden" name="igitem_id" value="<?php echo $InstaGalleryItem['ig_item_id']; ?>" />
197
+ <?php } ?>
198
+ </form>
199
+ <script>
200
+ jQuery(document).ready(function($){
201
+ $('input[name="ig_select_from"]').on('change',function(){
202
+ if(this.value == 'username'){
203
+ $('#ig-select-tag-wrap').hide(500, function() {
204
+ $('#ig-select-username-wrap').show( ).addClass('active');
205
+ }).removeClass('active');
206
+ }else{
207
+ $('#ig-select-username-wrap').hide(500, function() {
208
+ $('#ig-select-tag-wrap').show( ).addClass('active');
209
+ }).removeClass('active');
210
+ }
211
+
212
+ });
213
+ $('input[name="ig_display_type"]').on('change',function(){
214
+
215
+ if(this.value == 'gallery'){
216
+ $('#ig-section-as-slider').hide(500, function() {
217
+ $('#ig-section-as-galllery').show( ).addClass('active');
218
+ }).removeClass('active');
219
+ }else{
220
+ $('#ig-section-as-galllery').hide(500, function() {
221
+ $('#ig-section-as-slider').show( ).addClass('active');
222
+ }).removeClass('active');
223
+ }
224
+
225
+ });
226
+ $('#ig-form-update').on('submit',function(ev){
227
+ var select_from = $('input[name="ig_select_from"]:checked').val();
228
+ var $insta_user = $('input[name="insta_user"]');
229
+ var $insta_tag = $('input[name="insta_tag"]');
230
+ var valid = true;
231
+ if((select_from == 'username') && ($insta_user.val() == '')){
232
+ valid = false;
233
+ $('#ig-select-username-wrap').addClass('error');
234
+ }else if((select_from == 'tag') && ($insta_tag.val() == '')){
235
+ valid = false;
236
+ $('#ig-select-tag-wrap').addClass('error');
237
+ }
238
+ if( !valid ){
239
+
240
+ setTimeout(function(){$('#ig-select-tag-wrap,#ig-select-username-wrap').removeClass('error');},5000);
241
+ $('html, body').animate({
242
+ scrollTop: 100
243
+ }, 500);
244
+ ev.preventDefault();
245
+ return false;
246
+ }
247
+ });
248
+
249
+ });
250
+ </script>
app/views/list.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (! defined('ABSPATH')) {
3
+ die();
4
+ }
5
+ $InstaGalleryItems = get_option('insta_gallery_items');
6
+ ?>
7
+ <p>
8
+ <a href="<?php echo INSGALLERY_URL_ADMIN_PAGE; ?>&tab=edit" title="Add New Gallery" class="ig-btn"><span
9
+ class="dashicons dashicons-plus"></span>Add New Gallery</a>
10
+ </p>
11
+ <?php
12
+
13
+ // update_option( 'insta_gallery_items', '' );
14
+ // delete_option('wpshout_tut_option');
15
+ if (empty($InstaGalleryItems)) {
16
+ ?>
17
+ <h3 class="ig-no-items-msg">It looks like you have not added any gallery yet. Please Click on 'ADD NEW GALLERY' to add
18
+ one.</h3>
19
+ <?php } ?>
20
+
21
+ <?php if( !empty($InstaGalleryItems) && is_array($InstaGalleryItems) ){ ?>
22
+ <div>
23
+ <table class="widefat">
24
+ <thead>
25
+ <tr>
26
+ <th>Sr. No.</th>
27
+ <th>Item</th>
28
+ <th>Shortcode</th>
29
+ <th>Action</th>
30
+ </tr>
31
+ </thead>
32
+ <tbody>
33
+ <?php $i = 1; foreach($InstaGalleryItems as $k => $IGItem){ ?>
34
+ <tr>
35
+ <td><?php echo $i++; ?></td>
36
+ <td>
37
+ <?php
38
+
39
+ if ($IGItem['ig_select_from'] == 'username') {
40
+ echo 'Username / ' . $IGItem['insta_user'];
41
+ } else {
42
+ echo '# Tag / ' . $IGItem['insta_tag'];
43
+ }
44
+ ?>
45
+ </td>
46
+ <td><code>[insta-gallery id="<?php echo $k; ?>"]</code></td>
47
+ <td><a href="<?php echo INSGALLERY_URL_ADMIN_PAGE; ?>&tab=edit&ig_item=<?php echo $k; ?>" class="ig-btn"><span
48
+ class="dashicons dashicons-edit"></span> Edit</a> <a
49
+ href="<?php echo INSGALLERY_URL_ADMIN_PAGE; ?>&ig_item_delete=<?php echo $k; ?>" class="ig-btn"
50
+ onclick="return ig_item_delete();"><span class="dashicons dashicons-trash"></span> Delete</a></td>
51
+ </tr>
52
+ <?php } unset($i); ?>
53
+ </tbody>
54
+ </table>
55
+ </div>
56
+ <?php } ?>
57
+
58
+ <script>
59
+ function ig_item_delete(){
60
+ var c = confirm('Are you sure want to delete this item ?');
61
+ if(!c){
62
+ return false;
63
+ }
64
+
65
+ }
66
+
67
+ </script>
app/wp-front.php ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (! defined('ABSPATH')) {
3
+ die();
4
+ }
5
+
6
+ // Registering css.
7
+ add_action('wp_enqueue_scripts', 'insgal_enqueue_scripts');
8
+ function insgal_enqueue_scripts()
9
+ {
10
+ wp_enqueue_style('insta-gallery', INSGALLERY_URL . '/assests/style.css');
11
+ }
12
+ include_once (INSGALLERY_PATH . 'app/ig-spider.php');
13
+ // shortcode added
14
+ add_shortcode('insta-gallery', 'insta_gallery');
15
+ // Insta-Gallery shortcode handler
16
+ function insta_gallery($atts)
17
+ {
18
+ if (empty($atts) || ! isset($atts['id'])) {
19
+ return;
20
+ }
21
+ $gid = (int) $atts['id'];
22
+
23
+ $InstaGalleryItems = get_option('insta_gallery_items');
24
+ if (! isset($InstaGalleryItems[$gid])) {
25
+ return;
26
+ }
27
+ $IGItem = $InstaGalleryItems[$gid];
28
+ $igs = new InstagramSpider();
29
+
30
+ // validating options
31
+ if (empty($IGItem['ig_select_from'])) {
32
+ return;
33
+ }
34
+ $IGItem['insta_limit'] = (int) $IGItem['insta_limit'];
35
+ $IGItem['insta_limit'] = (($IGItem['insta_limit'] > 0) && ($IGItem['insta_limit'] <= 20)) ? $IGItem['insta_limit'] : 12;
36
+
37
+ $IGItem['insta_gal-popup'] = filter_var($IGItem['insta_gal-popup'], FILTER_VALIDATE_BOOLEAN);
38
+ $IGItem['insta_gal-hover'] = filter_var($IGItem['insta_gal-hover'], FILTER_VALIDATE_BOOLEAN);
39
+ $IGItem['insta_gal-spacing'] = filter_var($IGItem['insta_gal-spacing'], FILTER_VALIDATE_BOOLEAN);
40
+ $IGItem['insta_sli-navarrows'] = filter_var($IGItem['insta_sli-navarrows'],
41
+ FILTER_VALIDATE_BOOLEAN);
42
+ $IGItem['insta_sli-dots'] = filter_var($IGItem['insta_sli-dots'], FILTER_VALIDATE_BOOLEAN);
43
+ $IGItem['insta_sli-scroll'] = filter_var($IGItem['insta_sli-scroll'], FILTER_VALIDATE_BOOLEAN);
44
+
45
+ // continue to results
46
+ $results = '';
47
+ global $INSTAGAL_Results;
48
+ $instaItems = '';
49
+ if ($IGItem['ig_select_from'] == 'username') { //
50
+ if (empty($IGItem['insta_user'])) {
51
+ return; // return 'Please enter valid Instagram Account';
52
+ }
53
+ $instagram_user = $IGItem['insta_user'];
54
+ $instagram_reskey = 'username_' . $instagram_user; // backup result key
55
+
56
+ if (empty($INSTAGAL_Results[$instagram_reskey])) {
57
+ $INSTAGAL_Results[$instagram_reskey] = $igs->getUserItems($instagram_user);
58
+ }
59
+ $instaItems = $INSTAGAL_Results[$instagram_reskey];
60
+ } else { // continue to tag
61
+ if (empty($IGItem['insta_tag'])) {
62
+ return; // return 'Please enter valid Instagram Tag';
63
+ }
64
+
65
+ $instagram_tag = $IGItem['insta_tag'];
66
+ $instagram_reskey = 'tag_' . $instagram_tag; // backup result key
67
+
68
+ if (empty($INSTAGAL_Results[$instagram_reskey])) {
69
+ $INSTAGAL_Results[$instagram_reskey] = $igs->getTagItems($instagram_tag);
70
+ }
71
+ $instaItems = $INSTAGAL_Results[$instagram_reskey];
72
+ }
73
+
74
+
75
+ if (! empty($instaItems)) {
76
+ if ($IGItem['ig_display_type'] == 'gallery') {
77
+ include (INSGALLERY_PATH . 'templates/gallery.php');
78
+ } else {
79
+ include (INSGALLERY_PATH . 'templates/slider.php');
80
+ }
81
+ } else {
82
+ if (current_user_can('administrator')) {
83
+ $results .= '<p>ERROR: unable to get results. possible reasons:';
84
+ $results .= '<ul>';
85
+ $results .= '<li>your Instagram account may be private.</li>';
86
+ $results .= '<li>inavalid Instagram tag.</li>';
87
+ $results .= '<li>some other network or server issue.</li>';
88
+ $results .= '</ul>';
89
+ }
90
+ }
91
+ return $results;
92
+ }
93
+
94
+ /**
95
+ * ****
96
+ *
97
+ *
98
+ * below is for OLD shortcode support
99
+ */
100
+ // shortcode added
101
+ add_shortcode('Insta-Gallery', 'instaGallery');
102
+
103
+ // Insta-Gallery shortcode handler
104
+ function instaGallery($atts)
105
+ {
106
+ $av = shortcode_atts(
107
+ array('user' => '','limit' => '12','type' => '','gal_cols' => '3','gal_imgpopup' => true,
108
+ 'gal_imghover' => true,'sli_effect' => 'fade','sli_timeout' => 5000,
109
+ 'sli_navarrows' => true,'sli_dots' => true,'sli_scroll' => true
110
+ ), $atts);
111
+
112
+ $av['gal_imgpopup'] = filter_var($av['gal_imgpopup'], FILTER_VALIDATE_BOOLEAN);
113
+ $av['gal_imghover'] = filter_var($av['gal_imghover'], FILTER_VALIDATE_BOOLEAN);
114
+ $av['sli_navarrows'] = filter_var($av['sli_navarrows'], FILTER_VALIDATE_BOOLEAN);
115
+ $av['sli_dots'] = filter_var($av['sli_dots'], FILTER_VALIDATE_BOOLEAN);
116
+ $av['sli_scroll'] = filter_var($av['sli_scroll'], FILTER_VALIDATE_BOOLEAN);
117
+
118
+ if (empty($av['user']))
119
+ return 'Please enter valid Instagram Account';
120
+ $results = '';
121
+ global $INSTAGAL_Results;
122
+
123
+ $instagram_user = $av['user'];
124
+ $instagram_user = trim($instagram_user);
125
+ if (substr($instagram_user, 0, 1) == '@')
126
+ $instagram_user = substr($instagram_user, 1);
127
+ if (! empty($INSTAGAL_Results[$instagram_user])) {
128
+ $instaItems = $INSTAGAL_Results[$instagram_user];
129
+ } else {
130
+
131
+ $inURL = 'https://www.instagram.com/' . $instagram_user . '/media/';
132
+ $instaItems = '';
133
+ if (function_exists('curl_version')) {
134
+ $ch = curl_init();
135
+ curl_setopt($ch, CURLOPT_URL, $inURL);
136
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
137
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
138
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
139
+ $contents = curl_exec($ch);
140
+ if (curl_error($ch)) {
141
+ // for debugging
142
+ // echo 'error:' . curl_error($ch);
143
+ }
144
+ curl_close($ch);
145
+ $instaItems = $contents;
146
+ } else {
147
+ if (ini_get('allow_url_fopen')) {
148
+ $instaItems = @file_get_contents($inURL);
149
+ } else {
150
+ if (current_user_can('administrator')) {
151
+ $results .= '<p>Your server does\'t have enabled the required extensions/functions.</p>';
152
+ } else {
153
+ // nothing to show
154
+ }
155
+ }
156
+ }
157
+
158
+ $INSTAGAL_Results[$instagram_user] = $instaItems;
159
+ }
160
+
161
+ $instaItems = @json_decode($instaItems);
162
+ if (! empty($instaItems->items)) {
163
+ if ($av['type'] == 'gallery') {
164
+ include (INSGALLERY_PATH . '/templates/gallery-OLD.php');
165
+ } else {
166
+ include (INSGALLERY_PATH . '/templates/slider-OLD.php');
167
+ }
168
+ } else {
169
+ if (current_user_can('administrator')) {
170
+ $results .= '<p>ERROR: unable to get results. your instagram account may be private OR other issue. </p>';
171
+ }
172
+ }
173
+ // deprecated warning
174
+ if (current_user_can('administrator')) {
175
+ $results .= '<p class="ig-deprecated-shortcode" style="color:#e23565;"> Deprecated Shortcode: It looks like you are using OLD shortcode. Please goto Instagram Gallery plugin page and generate a new Shortcode. </p>';
176
+ }
177
+ return $results;
178
+ }
179
+
180
+
app/wp-panel.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Instagram Gallery
4
+ * WP admin panel plugin page
5
+ */
6
+ // current page url
7
+ define('INSGALLERY_URL_ADMIN_PAGE', menu_page_url('insta_gallery', false));
8
+
9
+ $InstaGalleryItems = get_option('insta_gallery_items');
10
+ $ig_page_msgs = array();
11
+ // add/update gallery item
12
+ if (isset($_POST['ig-form-update'])) {
13
+ // filtering data
14
+ $POSTDATA = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
15
+ $IGItem = array();
16
+ $IGItem['ig_select_from'] = $POSTDATA['ig_select_from'];
17
+ $IGItem['insta_user'] = (string)$POSTDATA['insta_user'];
18
+ $IGItem['insta_tag'] = (string)$POSTDATA['insta_tag'];
19
+ $IGItem['insta_limit'] = $POSTDATA['insta_limit'];
20
+ $IGItem['ig_display_type'] = $POSTDATA['ig_display_type'];
21
+ $IGItem['insta_gal-cols'] = $POSTDATA['insta_gal-cols'];
22
+ $IGItem['insta_gal-popup'] = @$POSTDATA['insta_gal-popup'];
23
+ $IGItem['insta_gal-hover'] = @$POSTDATA['insta_gal-hover'];
24
+ $IGItem['insta_gal-spacing'] = @$POSTDATA['insta_gal-spacing'];
25
+ $IGItem['insta_sli-effect'] = $POSTDATA['insta_sli-effect'];
26
+ $IGItem['insta_sli-timeout'] = $POSTDATA['insta_sli-timeout'];
27
+ $IGItem['insta_sli-navarrows'] = @$POSTDATA['insta_sli-navarrows'];
28
+ $IGItem['insta_sli-dots'] = @$POSTDATA['insta_sli-dots'];
29
+ $IGItem['insta_sli-scroll'] = @$POSTDATA['insta_sli-scroll'];
30
+
31
+ // removing @, # and trimming input
32
+ $IGItem['insta_user'] = trim($IGItem['insta_user']);
33
+ $IGItem['insta_tag'] = trim($IGItem['insta_tag']);
34
+ if (substr($IGItem['insta_user'], 0, 1) == '@')
35
+ $IGItem['insta_user'] = substr($IGItem['insta_user'], 1);
36
+ if (substr($IGItem['insta_tag'], 0, 1) == '#')
37
+ $IGItem['insta_tag'] = substr($IGItem['insta_tag'], 1);
38
+
39
+ if (isset($POSTDATA['igitem_id'])) {
40
+ $InstaGalleryItems[(int) $POSTDATA['igitem_id']] = $IGItem;
41
+ } else {
42
+ $InstaGalleryItems[] = $IGItem;
43
+ if (isset($InstaGalleryItems[0])) { // for preventing 0 key generation
44
+ $InstaGalleryItems[] = $InstaGalleryItems[0];
45
+ unset($InstaGalleryItems[0]);
46
+ }
47
+ }
48
+ update_option('insta_gallery_items', $InstaGalleryItems);
49
+ $ig_page_msgs[] = 'Gallery item updated successfully.';
50
+ }
51
+
52
+ // delete gallery item
53
+ if (isset($_GET['ig_item_delete'])) {
54
+ $item_id = (int) $_GET['ig_item_delete'];
55
+ if (isset($InstaGalleryItems[$item_id])) {
56
+ unset($InstaGalleryItems[$item_id]);
57
+ update_option('insta_gallery_items', $InstaGalleryItems);
58
+ }
59
+ $ig_page_msgs[] = 'Gallery item deleted successfully.';
60
+ }
61
+
62
+ ?>
63
+ <div id="ig-page">
64
+ <div class="wrap">
65
+ <header class="ig-page-header">
66
+ <img src="<?php echo INSGALLERY_URL; ?>/assests/media/icon-128x128.jpg" class="ig-logo" />
67
+ <h3>Instagram Gallery:</h3>
68
+ <p>easy way to display your Instagram pictures on the website.</p>
69
+ </header>
70
+ <hr />
71
+ <div class="ig-page-content">
72
+ <?php
73
+ if (! empty($ig_page_msgs)) {
74
+ foreach ($ig_page_msgs as $ig_page_msg) {
75
+ echo '<div class="notice updated my-acf-notice is-dismissible ig_page_msg" ><p>' .
76
+ $ig_page_msg . '</p></div>';
77
+ }
78
+ }
79
+ ?>
80
+ <?php
81
+ if (isset($_GET['tab']) && ! empty($_GET['tab'])) {
82
+ $tab = (string) $_GET['tab'];
83
+ switch ($tab) {
84
+ case 'edit':
85
+ include 'views/edit.php';
86
+ break;
87
+ default:
88
+ break;
89
+ }
90
+ } else {
91
+ include 'views/list.php';
92
+ }
93
+ ?>
94
+ </div>
95
+ <hr />
96
+ </div>
97
+ </div>
98
+
assests/admin-style.css ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @CHARSET "ISO-8859-1";
2
+
3
+ .ig-page-header .ig-logo {
4
+ float: left;
5
+ margin-right: 20px;
6
+ max-height: 55px;
7
+ }
8
+
9
+ .ig-no-items-msg {
10
+ background: #ddd;
11
+ padding: 50px 30px;
12
+ color: #dd2b74;
13
+ font-size: 22px;
14
+ }
15
+
16
+ .ig-list-buttons {
17
+ display: inline-block;
18
+ margin: 0px;
19
+ }
20
+
21
+ .ig-list-buttons li {
22
+ display: inline-block;
23
+ margin-right: 20px;
24
+ margin-bottom: 0px;
25
+ vertical-align: middle;
26
+ color: #AAAAAA;
27
+ position: relative;
28
+ }
29
+
30
+ .ig-list-buttons input[type=radio] {
31
+ position: absolute;
32
+ visibility: hidden;
33
+ }
34
+
35
+ .ig-list-buttons label {
36
+ display: block;
37
+ position: relative;
38
+ font-size: 1.35em;
39
+ padding: 10px 5px 10px 50px;
40
+ z-index: 9;
41
+ cursor: pointer;
42
+ -webkit-transition: all 0.25s linear;
43
+ }
44
+
45
+ .ig-list-buttons li:hover label {
46
+ color: #e23565;
47
+ }
48
+
49
+ .ig-list-buttons li .check {
50
+ display: block;
51
+ position: absolute;
52
+ border: 5px solid #AAAAAA;
53
+ border-radius: 50%;
54
+ height: 25px;
55
+ width: 25px;
56
+ top: 5px;
57
+ left: 10px;
58
+ z-index: 5;
59
+ transition: border .25s linear;
60
+ -webkit-transition: border .25s linear;
61
+ }
62
+
63
+ .ig-list-buttons li:hover .check {
64
+ border-color: #e23565;
65
+ }
66
+
67
+ .ig-list-buttons li .check::before {
68
+ display: block;
69
+ position: absolute;
70
+ content: '';
71
+ border-radius: 100%;
72
+ height: 15px;
73
+ width: 15px;
74
+ top: 5px;
75
+ left: 5px;
76
+ margin: auto;
77
+ transition: background 0.25s linear;
78
+ -webkit-transition: background 0.25s linear;
79
+ }
80
+
81
+ .ig-list-buttons input[type=radio]:checked ~ .check {
82
+ border-color: #e23565;
83
+ }
84
+
85
+ .ig-list-buttons input[type=radio]:checked ~ .check::before {
86
+ background: #e23565;
87
+ }
88
+
89
+ .ig-list-buttons input[type=radio]:checked ~ label {
90
+ color: #e23565;
91
+ }
92
+
93
+ .ig-btn {
94
+ display: inline-block;
95
+ padding: 5px 20px;
96
+ background: #972dbe;
97
+ color: #fff;
98
+ text-transform: uppercase;
99
+ text-decoration: none;
100
+ transition: all .5s;
101
+ }
102
+
103
+ .ig-btn:hover {
104
+ background: #feb547;
105
+ color: #fff;
106
+ }
107
+
108
+ .ig-btn .dashicons {
109
+ text-decoration: none;
110
+ line-height: normal;
111
+ vertical-align: middle;
112
+ height: initial;
113
+ padding-right: 5px;
114
+ }
115
+
116
+ .ig-tab-content-row {
117
+ display: none;
118
+ border: 1px solid #fff;
119
+ }
120
+
121
+ .ig-tab-content-row.active {
122
+ display: table-row;
123
+ }
124
+
125
+ .ig-generate-msgs {
126
+ color: #e23565;
127
+ display: none;
128
+ }
129
+ .ig-tab-content-row.error{
130
+ border-color: #e23565;
131
+ }
132
+ .ig-tab-content-row.error .ig-generate-msgs {
133
+ display: block;
134
+ }
135
+ .ig_page_msg p{
136
+ font-size: 20px;
137
+ color: #e93b59;
138
+ }
139
+ .wp-core-ui .button-primary.ig-add-update {
140
+ background: #e23565;
141
+ font-size: 20px;
142
+ padding: 6px 15px;
143
+ height: auto;
144
+ margin: 15px 0px;
145
+ box-shadow: none;
146
+ text-shadow: none;
147
+ transition: all .5s;
148
+ border-color: #fff;
149
+ }
150
+
151
+ .wp-core-ui .button-primary.ig-add-update:hover {
152
+ background: #feb547;
153
+ color: #fff;
154
+ }
155
+
156
+ .ig-add-update .dashicons {
157
+ vertical-align: middle;
158
+ }
159
+
160
+ .ig-table-edit th {
161
+ vertical-align: middle;
162
+ }
163
+
164
+ .ig-table-edit input[type="checkbox"] {
165
+ zoom: 1.5;
166
+ }
167
+ .ig-table-edit input[type="checkbox"]:checked:before {
168
+ color: #e23565;
169
+ }
assests/media/demo-gallery.jpg CHANGED
Binary file
assests/media/demo-slider.jpg CHANGED
Binary file
assests/style.css CHANGED
@@ -377,8 +377,12 @@ img.mfp-img {
377
  box-sizing: border-box;
378
  text-align: center;
379
  }
 
 
 
380
  .ig-item a{
381
  display: inline-block;
 
382
  position: relative;
383
  text-align: center;
384
  }
@@ -420,12 +424,28 @@ img.mfp-img {
420
  /*
421
  * responsive
422
  */
 
 
 
 
 
 
 
 
423
  @media screen and (max-width: 767px) {
424
 
425
- .ig-item.ighover{
426
  min-width: 50%;
427
  padding: 5px;
428
  }
429
 
430
  }
 
 
 
 
 
 
 
 
431
 
377
  box-sizing: border-box;
378
  text-align: center;
379
  }
380
+ .ig-item.no-spacing {
381
+ padding: 0px;
382
+ }
383
  .ig-item a{
384
  display: inline-block;
385
+ width: 100%;
386
  position: relative;
387
  text-align: center;
388
  }
424
  /*
425
  * responsive
426
  */
427
+ @media screen and (max-width: 1023px) and (min-width: 768px) {
428
+
429
+ .ig-item{
430
+ min-width: 33.333%;
431
+ padding: 10px;
432
+ }
433
+
434
+ }
435
  @media screen and (max-width: 767px) {
436
 
437
+ .ig-item{
438
  min-width: 50%;
439
  padding: 5px;
440
  }
441
 
442
  }
443
+ @media screen and (max-width: 420px) {
444
+
445
+ .ig-item{
446
+ min-width: 100%;
447
+ padding: 5px;
448
+ }
449
+
450
+ }
451
 
insta-gallery.php CHANGED
@@ -3,7 +3,9 @@
3
  * Plugin Name: Instagram Gallery
4
  * Description: Display pictures on your website from Instagram.
5
  * Author: Karan Singh
6
- * Version: 1.1.3
 
 
7
  */
8
 
9
  // plugin global constants
@@ -16,23 +18,28 @@ class INSGALLERY
16
 
17
  public function __construct()
18
  {
19
- register_activation_hook(__FILE__, array(
20
- $this,
21
- 'activate'
22
- ));
23
  register_deactivation_hook(__FILE__,
24
- array(
25
- $this,
26
- 'deactivate'
27
  ));
28
 
29
  if (is_admin()) {
30
- add_action('admin_menu', array(
31
- $this,
32
- 'loadMenus'
33
- ));
 
 
 
34
  }
35
- include_once (INSGALLERY_PATH . '/libs/wp-front.php');
 
 
 
 
 
36
  }
37
 
38
  public function activate()
@@ -41,19 +48,46 @@ class INSGALLERY
41
  public function deactivate()
42
  {}
43
 
 
 
 
 
 
 
 
 
 
44
  function loadMenus()
45
  {
46
- add_options_page('Instagram Gallery', 'Instagram Gallery', 'manage_options', 'insta_gallery',
47
- array(
48
- $this,
49
- 'loadPanel'
50
  ));
51
  // add_menu_page();
52
  }
53
 
54
  function loadPanel()
55
  {
56
- require_once (INSGALLERY_PATH . '/libs/wp-panel.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  }
58
  }
59
  new INSGALLERY();
3
  * Plugin Name: Instagram Gallery
4
  * Description: Display pictures on your website from Instagram.
5
  * Author: Karan Singh
6
+ * Author URI: http://karansingh.ml/
7
+ * Text Domain: insta-gallery
8
+ * Version: 1.2.4
9
  */
10
 
11
  // plugin global constants
18
 
19
  public function __construct()
20
  {
21
+ register_activation_hook(__FILE__,
22
+ array($this,'activate'
23
+ ));
 
24
  register_deactivation_hook(__FILE__,
25
+ array($this,'deactivate'
 
 
26
  ));
27
 
28
  if (is_admin()) {
29
+ add_action('admin_menu',
30
+ array($this,'loadMenus'
31
+ ));
32
+ // add setting link
33
+ add_filter('plugin_action_links',
34
+ array($this,'insgal_add_action_plugin'
35
+ ), 10, 5);
36
  }
37
+
38
+ add_action('admin_enqueue_scripts',
39
+ array($this,'load_admin_scripts'
40
+ ));
41
+
42
+ include_once (INSGALLERY_PATH . 'app/wp-front.php');
43
  }
44
 
45
  public function activate()
48
  public function deactivate()
49
  {}
50
 
51
+ function load_admin_scripts($hook)
52
+ {
53
+ // Load only on plugin page
54
+ if ($hook != 'settings_page_insta_gallery') {
55
+ return;
56
+ }
57
+ wp_enqueue_style('insta-gallery-admin', INSGALLERY_URL . '/assests/admin-style.css');
58
+ }
59
+
60
  function loadMenus()
61
  {
62
+ add_options_page('Instagram Gallery', 'Instagram Gallery', 'manage_options',
63
+ 'insta_gallery',
64
+ array($this,'loadPanel'
 
65
  ));
66
  // add_menu_page();
67
  }
68
 
69
  function loadPanel()
70
  {
71
+ require_once (INSGALLERY_PATH . 'app/wp-panel.php');
72
+ }
73
+
74
+ function insgal_add_action_plugin($actions, $plugin_file)
75
+ {
76
+ static $plugin;
77
+
78
+ if (! isset($plugin))
79
+ $plugin = plugin_basename(__FILE__);
80
+ if ($plugin == $plugin_file) {
81
+
82
+ $settings = array(
83
+ 'settings' => '<a href="options-general.php?page=insta_gallery">' .
84
+ __('Settings', 'General') . '</a>'
85
+ );
86
+
87
+ $actions = array_merge($settings, $actions);
88
+ }
89
+
90
+ return $actions;
91
  }
92
  }
93
  new INSGALLERY();
libs/wp-front.php DELETED
@@ -1,95 +0,0 @@
1
- <?php
2
- // Registering css. (Added outside the shortcode script for w3validation and seo solution
3
- add_action('wp_enqueue_scripts',
4
- function () {
5
- wp_enqueue_style('insta-gallery', INSGALLERY_URL . '/assests/style.css');
6
- });
7
- add_shortcode('Insta-Gallery', 'instaGallery');
8
-
9
- // Insta-Gallery shortcode handler
10
- function instaGallery($atts)
11
- {
12
- $av = shortcode_atts(
13
- array(
14
- 'user' => '',
15
- 'limit' => '12',
16
- 'type' => '',
17
- 'gal_cols' => '3',
18
- 'gal_imgpopup' => true,
19
- 'gal_imghover' => true,
20
- 'sli_effect' => 'fade',
21
- 'sli_timeout' => 5000,
22
- 'sli_navarrows' => true,
23
- 'sli_dots' => true,
24
- 'sli_scroll' => true
25
- ), $atts);
26
-
27
- $av['gal_imgpopup'] = filter_var($av['gal_imgpopup'], FILTER_VALIDATE_BOOLEAN);
28
- $av['gal_imghover'] = filter_var($av['gal_imghover'], FILTER_VALIDATE_BOOLEAN);
29
- $av['sli_navarrows'] = filter_var($av['sli_navarrows'], FILTER_VALIDATE_BOOLEAN);
30
- $av['sli_dots'] = filter_var($av['sli_dots'], FILTER_VALIDATE_BOOLEAN);
31
- $av['sli_scroll'] = filter_var($av['sli_scroll'], FILTER_VALIDATE_BOOLEAN);
32
-
33
- if (empty($av['user']))
34
- return 'Please enter valid Instagram Account';
35
- $results = '';
36
- global $INSTAGAL_Results;
37
-
38
-
39
-
40
- $instagram_user = $av['user'];
41
- $instagram_user = trim($instagram_user);
42
- if (substr($instagram_user, 0, 1) == '@')
43
- $instagram_user = substr($instagram_user, 1);
44
- if (! empty($INSTAGAL_Results[$instagram_user])) {
45
- $instaItems = $INSTAGAL_Results[$instagram_user];
46
- } else {
47
-
48
-
49
-
50
- $inURL = 'https://www.instagram.com/' . $instagram_user . '/media/';
51
- $instaItems = '';
52
- if (function_exists('curl_version')) {
53
- $ch = curl_init();
54
- curl_setopt($ch, CURLOPT_URL, $inURL);
55
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
56
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
57
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
58
- $contents = curl_exec($ch);
59
- if (curl_error($ch)) {
60
- // for debugging
61
- // echo 'error:' . curl_error($ch);
62
- }
63
- curl_close($ch);
64
- $instaItems = $contents;
65
- } else {
66
- if (ini_get('allow_url_fopen')) {
67
- $instaItems = @file_get_contents($inURL);
68
- } else {
69
- if (current_user_can('administrator')) {
70
- $results .= '<p>Your server does\'t have enabled the required extensions/functions.</p>';
71
- } else {
72
- // nothing to show
73
- }
74
- }
75
- }
76
-
77
- $INSTAGAL_Results[$instagram_user] = $instaItems;
78
- }
79
-
80
- $instaItems = @json_decode($instaItems);
81
- if (! empty($instaItems->items)) {
82
- if ($av['type'] == 'gallery') {
83
- include (INSGALLERY_PATH . '/templates/gallery.php');
84
- } else {
85
- include (INSGALLERY_PATH . '/templates/slider.php');
86
- }
87
- } else {
88
- if (current_user_can('administrator')) {
89
- $results .= '<p>ERROR: unable to get results. your instagram account may be private OR other issue. </p>';
90
- }
91
- }
92
- return $results;
93
- }
94
-
95
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
libs/wp-panel.php DELETED
@@ -1,237 +0,0 @@
1
- <?php
2
- $msgs = array();
3
- ?>
4
- <div id="ig-wp-panel">
5
- <style>
6
- #ig-wp-panel .ig-logo {
7
- float: left;
8
- margin-right: 20px;
9
- max-height: 55px;
10
- }
11
-
12
- .ig-btn-choose {
13
- border: 1px solid grey;
14
- padding: 5px 15px;
15
- background: #d6d6d6;
16
- }
17
-
18
- .ig-btn-choose.active {
19
- border: 1px solid #fff;
20
- background: #2196F3;
21
- color: #fff;
22
- }
23
-
24
- .ig-btn-choose .dashicons-yes {
25
- vertical-align: middle;
26
- margin-right: 5px;
27
- }
28
-
29
- .ig-btn-choose.active .dashicons-yes {
30
- color: #fff;
31
- }
32
-
33
- .ig-tab-content {
34
- display: none;
35
- }
36
-
37
- .ig-tab-content.active {
38
- border: 1px solid #fff;
39
- }
40
-
41
- .ig-generate-msgs {
42
- color: red;
43
- }
44
-
45
- .wp-core-ui .button-primary.ig-generate {
46
- background: #2196f3;
47
- font-size: 20px;
48
- padding: 6px 15px;
49
- height: auto;
50
- margin: 15px 0px;
51
- box-shadow: none;
52
- text-shadow: none;
53
- }
54
-
55
- .wp-core-ui .button-primary.ig-generate:hover {
56
- background: #0073aa;
57
- }
58
-
59
- .ig-generate .dashicons-arrow-right-alt2 {
60
- vertical-align: middle;
61
- }
62
-
63
- .ig-results {
64
- display: none;
65
- }
66
-
67
- .ig-results textarea {
68
- font-size: 150%;
69
- }
70
- #ig-wp-panel th {
71
- vertical-align: middle;
72
- }
73
- #ig-wp-panel table input[type="checkbox"] {
74
- zoom: 1.5;
75
- }
76
- </style>
77
- <div class="wrap">
78
- <header>
79
- <img src="<?php echo INSGALLERY_URL; ?>/assests/media/icon-128x128.jpg" class="ig-logo" />
80
- <h2>Instagram Gallery:</h2>
81
- <p>fillup the below details and and click on 'Generate ShortCode' button. Then use the generated code in your
82
- posts/pages.</p>
83
- </header>
84
- <hr />
85
- <table class="form-table">
86
- <tbody>
87
- <tr>
88
- <th scope="row">Instagram User Name:</th>
89
- <td><input name="insta_user" type="text" placeholder="MyUsername" /> <span class="description">e.g.
90
- https://www.instagram.com/<strong style="font-size: 120%; color: #0085ba;">MyUsername</strong>/
91
- </span></td>
92
- </tr>
93
- <tr>
94
- <th scope="row">Pictures Limit:</th>
95
- <td><input name="insta_limit" type="number" min="1" max="20" value="12" /> <span class="description">no. of pics to
96
- display. use 0 for all. (max: 20)</span></td>
97
- </tr>
98
- <tr>
99
- <th scope="row">Show As:</th>
100
- <td><label id="btn-as-gallery" class="ig-btn-choose"><span class="dashicons dashicons-yes"></span>Galllery</label>
101
- <label id="btn-as-slider" class="ig-btn-choose"><span class="dashicons dashicons-yes"></span>Slider</label></td>
102
- </tr>
103
- <tr id="section-as-galllery" class="ig-tab-content">
104
- <td colspan="2">
105
- <table>
106
- <tr>
107
- <th scope="row">No. of Pics Columns:</th>
108
- <td><input name="insta_gal-cols" type="number" min="1" max="20" value="3" /> <span class="description">no. of
109
- pics in a row. </span></td>
110
- <td rowspan="3"><img src="<?php echo INSGALLERY_URL; ?>/assests/media/demo-gallery.jpg" alt="demo gallery"
111
- width="500" /></td>
112
- </tr>
113
- <tr>
114
- <th scope="row">Popup image on click:</th>
115
- <td><input name="insta_gal-popup" type="checkbox" value="1" checked /> <span class="description">show popup
116
- gallery by clicking on image <br />( disable this if it conflicts with other plugins)</span></td>
117
- </tr>
118
- </tr>
119
- <tr>
120
- <th scope="row">image hover effect:</th>
121
- <td><input name="insta_gal-hover" type="checkbox" value="1" checked /> <span class="description">animation
122
- effectby hovering on image </span></td>
123
- </tr>
124
- </table>
125
- </td>
126
- </tr>
127
- <tr id="section-as-slider" class="ig-tab-content">
128
- <td colspan="2">
129
- <table>
130
- <tr>
131
- <th scope="row">Slide effect:</th>
132
- <td><select name="insta_sli-effect">
133
- <option value="fade">fade</option>
134
- <option value="slide">slide</option>
135
- </select> <span class="description">sliding effect/animation. </span></td>
136
- <td rowspan="5"><img src="<?php echo INSGALLERY_URL; ?>/assests/media/demo-slider.jpg" alt="demo slider"
137
- width="500" /></td>
138
- </tr>
139
- <tr>
140
- <th scope="row">Slide timeout:</th>
141
- <td><input name="insta_sli-timeout" type="number" min="100" max="20000" value="5000" /> <span
142
- class="description">slide duration in seconds. </span></td>
143
- </tr>
144
- <tr>
145
- <th scope="row">Navigation arrows:</th>
146
- <td><input name="insta_sli-navarrows" type="checkbox" value="1" checked /> <span class="description">show
147
- prev-next navigation arrows. </span></td>
148
- </tr>
149
- <tr>
150
- <th scope="row">Dotted navigation:</th>
151
- <td><input name="insta_sli-dots" type="checkbox" value="1" checked /> <span class="description">show dotted
152
- navigation buttons. </span></td>
153
- </tr>
154
- <tr>
155
- <th scope="row">Scrollbar:</th>
156
- <td><input name="insta_sli-scroll" type="checkbox" value="1" checked /> <span class="description">show scrollbar
157
- on slider bottom. </span></td>
158
- </tr>
159
- </table>
160
- </td>
161
- </tr>
162
- </tbody>
163
- </table>
164
- <div>
165
- <button class="button-primary ig-generate">
166
- Generate ShortCode <span class="dashicons dashicons-arrow-right-alt2"></span>
167
- </button>
168
-
169
- </div>
170
- <hr />
171
- <br />
172
- </div>
173
- <div class="wrap ig-results">
174
- <p>
175
- <strong>copy/paste below shortcode in your page.</strong>
176
- </p>
177
- <textarea rows="3" cols="100" onclick="this.focus();this.select()"></textarea>
178
- </div>
179
- <script>
180
- jQuery(document).ready(function($){
181
- $('#btn-as-gallery').click(function(){
182
- if($(this).hasClass('active'))return true;
183
- $(this).addClass('active');
184
- $('#btn-as-slider').removeClass('active');
185
- $('#section-as-slider').hide("slow", function() {
186
- $('#section-as-galllery').show( "slow" ).addClass('active');
187
- }).removeClass('active');
188
- });
189
- $('#btn-as-slider').click(function(){
190
- if($(this).hasClass('active'))return true;
191
- $(this).addClass('active');
192
- $('#btn-as-gallery').removeClass('active');
193
- $('#section-as-galllery').hide("slow", function() {
194
- $('#section-as-slider').show( "slow" ).addClass('active');
195
- }).removeClass('active');
196
- });
197
- $('.ig-generate').click(function(ev){
198
- $('.ig-results').hide();
199
- $('.ig-results textarea').text('');
200
- $('.ig-generate-msgs').remove();
201
-
202
- var $insta_user = $('input[name="insta_user"]');
203
- if($insta_user.val() == ''){
204
- $insta_user.parent().append('<p class="ig-generate-msgs">Please enter Instagram User Name.</p>');
205
- $insta_user.focus();
206
- return;
207
- }
208
- if(! $('.ig-btn-choose').hasClass('active')){
209
- $('#btn-as-slider').parent().append('<p class="ig-generate-msgs">Please select output type.</p>');
210
- return;
211
- }
212
-
213
- $('.ig-results').show();
214
- var code = '[Insta-Gallery user="' + $insta_user.val() +'" ';
215
- code += ' limit="'+ $('[name="insta_limit"]').val() +'"';
216
-
217
- if($('#btn-as-gallery').hasClass('active')){
218
- code += ' type="gallery"';
219
- code += ' gal_cols="'+ $('[name="insta_gal-cols"]').val() +'"';
220
- code += ' gal_imgpopup="'+ $('[name="insta_gal-popup"]').is(':checked') +'"';
221
- code += ' gal_imghover="'+ $('[name="insta_gal-hover"]').is(':checked') +'"';
222
-
223
- }else{
224
- code += ' type="slider"';
225
- code += ' sli_effect="'+ $('[name="insta_sli-effect"]').val() +'"';
226
- code += ' sli_timeout="'+ $('[name="insta_sli-timeout"]').val() +'"';
227
- code += ' sli_navarrows="'+ $('[name="insta_sli-navarrows"]').is(':checked') +'"';
228
- code += ' sli_dots="'+ $('[name="insta_sli-dots"]').is(':checked') +'"';
229
- code += ' sli_scroll="'+ $('[name="insta_sli-scroll"]').is(':checked') +'"';
230
- }
231
- code += ']'
232
- $('.ig-results textarea').text(code);
233
- });
234
- });
235
- </script>
236
- </div>
237
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,29 +1,27 @@
1
  === Plugin Name ===
2
  Contributors: Karan Singh
3
- Tags: instagram, gallery, pictures, slider, images, image gallery, image slider, instagram galley, instagram pictures
4
  Requires at least: 3.8.0
5
  Tested up to: 4.7
6
- Stable tag: 1.1.3
7
  License: GPLv2 or later
8
- License URI: #
9
- Donate link: #
10
 
11
  Instagram Gallery is an easy way to display your Instagram pictures on the site.
12
 
13
  == Description ==
14
 
15
- This plugin is an easy and simple way to display your instagram images on the website.
16
- we can display pictures from instagram account as Gallery or as slider.
17
  this plugin updates new pictures as you upload new-one on Instagram.
18
 
19
- **Note:** you have to add your instagram account username/id.
20
  and profile needs to be publicly visible to show pictures.
21
 
22
- **Demo:** live demo is not available yet. you can check 'screenshots' tab for demo.
23
 
24
- **How to use:** generate shortcode from plugin panel and
25
- paste them in the pages/post content or
26
- use the "echo do_shortcode( '[MyShortcode]' );" php code to add them in PHP file.
27
 
28
 
29
  == Installation ==
@@ -42,13 +40,17 @@ Upload and install in the same way you'd install any other plugin OR see [HERE](
42
 
43
  == Frequently Asked Questions ==
44
 
45
- = can i add multiple shortcode in a page? =
46
 
47
- yes, you can add multiple shortcodes within a page.
48
 
49
- = do i have to enter API keys to display pics? =
50
 
51
- no, there is no need to enter API keys, just enter username and enjoy.
 
 
 
 
52
 
53
  == Screenshots ==
54
 
@@ -59,6 +61,14 @@ no, there is no need to enter API keys, just enter username and enjoy.
59
 
60
 
61
  == Changelog ==
 
 
 
 
 
 
 
 
62
  = 1.1.3 =
63
  * some issues fixed
64
  * css added to head for removing SEO and HTML validation issues
@@ -73,6 +83,11 @@ no, there is no need to enter API keys, just enter username and enjoy.
73
 
74
 
75
  == Upgrade Notice ==
 
 
 
 
 
76
 
77
  = 1.1.3 =
78
  don't worry, update now.
1
  === Plugin Name ===
2
  Contributors: Karan Singh
3
+ Tags: instagram, gallery, pictures, slider, images, image gallery, image slider, instagram gallery, instagram pictures
4
  Requires at least: 3.8.0
5
  Tested up to: 4.7
6
+ Stable tag: 1.2.4
7
  License: GPLv2 or later
8
+ License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
+ Donate link: https://www.paypal.me/karanpay
10
 
11
  Instagram Gallery is an easy way to display your Instagram pictures on the site.
12
 
13
  == Description ==
14
 
15
+ This plugin is an easy and simple way to display your Instagram images on the website.
16
+ we can display pictures from Instagram account as Gallery or as Slider. Now there is also an option to display pictures from #Tag.
17
  this plugin updates new pictures as you upload new-one on Instagram.
18
 
19
+ **Note:** you have to add your instagram account username.
20
  and profile needs to be publicly visible to show pictures.
21
 
22
+ **Demo:** you can see live demo [HERE](http://karansingh.ml/public/demo/insta-gallery/). or check 'screenshots' section for demo.
23
 
24
+ **How to use:** add new gallery in plugin setting panel, generate shortcode and paste them in the pages/post content OR use the "echo do_shortcode( '[MyShortcode]' );" php code to add them in PHP file.
 
 
25
 
26
 
27
  == Installation ==
40
 
41
  == Frequently Asked Questions ==
42
 
43
+ = can i add multiple galleries? =
44
 
45
+ yes, you can add multiple galleries within a page.
46
 
47
+ = why my pictures are not showing on page? =
48
 
49
+ profile needs to be publicly visible to show pictures.
50
+
51
+ = can i display pictures by using #Tag? =
52
+
53
+ Yes you can.
54
 
55
  == Screenshots ==
56
 
61
 
62
 
63
  == Changelog ==
64
+ = 1.2.4 =
65
+ * IE images issue fixed
66
+
67
+ = 1.2.3 =
68
+ * Admin Panel UI updated
69
+ * added #tag support
70
+ * shortcode updated
71
+
72
  = 1.1.3 =
73
  * some issues fixed
74
  * css added to head for removing SEO and HTML validation issues
83
 
84
 
85
  == Upgrade Notice ==
86
+ = 1.2.3 =
87
+ update to fix IE issues
88
+
89
+ = 1.2.3 =
90
+ major update, update old shortcode to new-one
91
 
92
  = 1.1.3 =
93
  don't worry, update now.
templates/gallery-OLD.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $insta_limit = $av['limit'];
3
+ $gal_cols = $av['gal_cols'];
4
+ $gal_imgpopup = $av['gal_imgpopup'];
5
+ $gal_imghover = $av['gal_imghover'];
6
+
7
+ global $instagal_COUNT;
8
+ if(empty($instagal_COUNT))$instagal_COUNT = 0;
9
+ $instagal_COUNT++;
10
+ // Registering scripts.
11
+ if ($gal_imgpopup) {
12
+ // wp_enqueue_style('magnific', INSGALLERY_URL . '/assests/magnific-popup/magnific-popup.css');
13
+ wp_enqueue_script('magnific', INSGALLERY_URL . '/assests/magnific-popup/jquery.magnific-popup.min.js');
14
+ }
15
+ $i = 1;
16
+
17
+ $results .= '<div class="instagallery-items" id="instagallery-'.$instagal_COUNT.'">';
18
+ foreach ($instaItems->items as $item) {
19
+ if (! empty($item->images)) {
20
+ $img_src = ($gal_cols == 1) ? $item->images->standard_resolution->url : $item->images->low_resolution->url;
21
+ $hovered = $gal_imghover ? 'ighover' : '';
22
+ $results .= '<div class="ig-item '.$hovered.' cols-' . $gal_cols . '" style="width:' . (100 / $gal_cols) . '%;">';
23
+
24
+ $results .= '<a href="' . $item->images->standard_resolution->url . '">';
25
+ $results .= '<img src="' . $img_src . '" />';
26
+ $results .= '</a>';
27
+ $results .= '</div>';
28
+ }
29
+ $i ++;
30
+ if (($insta_limit != 0) && ($i > $insta_limit))
31
+ break;
32
+ }
33
+ $results .= '</div>';
34
+
35
+ if ($gal_imgpopup) {
36
+
37
+ $JSIGSelector = '#instagallery-'.$instagal_COUNT.' .ig-item a';
38
+ $rs = <<<JS
39
+ <script>
40
+ jQuery(document).ready(function ($) {
41
+ jQuery('$JSIGSelector').magnificPopup({
42
+ type: 'image',
43
+ mainClass: 'mfp-with-zoom',
44
+ zoom: {
45
+ enabled: true,
46
+ duration: 300,
47
+ easing: 'ease-in-out',
48
+ opener: function(openerElement) {
49
+ return openerElement.is('img') ? openerElement : openerElement.find('img');
50
+ }
51
+ },
52
+ gallery: {
53
+ enabled: true
54
+ },
55
+ });
56
+ });
57
+ </script>
58
+ JS;
59
+ $results .= $rs;
60
+ }
61
+ return $results;
templates/gallery.php CHANGED
@@ -1,9 +1,12 @@
1
  <?php
2
- $insta_limit = $av['limit'];
3
- $gal_cols = $av['gal_cols'];
4
- $gal_imgpopup = $av['gal_imgpopup'];
5
- $gal_imghover = $av['gal_imghover'];
 
6
 
 
 
7
  global $instagal_COUNT;
8
  if(empty($instagal_COUNT))$instagal_COUNT = 0;
9
  $instagal_COUNT++;
@@ -14,18 +17,28 @@ if ($gal_imgpopup) {
14
  }
15
  $i = 1;
16
 
17
- $results .= '<div class="instagallery-items" id="instagallery-'.$instagal_COUNT.'">';
18
- foreach ($instaItems->items as $item) {
19
- if (! empty($item->images)) {
20
- $img_src = ($gal_cols == 1) ? $item->images->standard_resolution->url : $item->images->low_resolution->url;
 
 
 
 
 
 
 
 
 
21
  $hovered = $gal_imghover ? 'ighover' : '';
22
- $results .= '<div class="ig-item '.$hovered.' cols-' . $gal_cols . '" style="width:' . (100 / $gal_cols) . '%;">';
 
23
 
24
- $results .= '<a href="' . $item->images->standard_resolution->url . '">';
25
- $results .= '<img src="' . $img_src . '" />';
26
  $results .= '</a>';
27
  $results .= '</div>';
28
- }
29
  $i ++;
30
  if (($insta_limit != 0) && ($i > $insta_limit))
31
  break;
1
  <?php
2
+ $insta_limit = $IGItem['insta_limit'];
3
+ $gal_cols = $IGItem['insta_gal-cols'];
4
+ $gal_imgpopup = $IGItem['insta_gal-popup'];
5
+ $gal_imghover = $IGItem['insta_gal-hover'];
6
+ $gal_imgspacing = $IGItem['insta_gal-spacing'];
7
 
8
+ $insta_source = ($IGItem['ig_select_from'] == 'username') ? 'user_'. $IGItem['insta_user'] : 'tag_'. $IGItem['insta_tag'];
9
+
10
  global $instagal_COUNT;
11
  if(empty($instagal_COUNT))$instagal_COUNT = 0;
12
  $instagal_COUNT++;
17
  }
18
  $i = 1;
19
 
20
+ // fix for <= IE8 browsers
21
+ $results .= '<!--[if lt IE 9]>
22
+ <style>
23
+ .ig-item.ighover a:hover:after {
24
+ background: none;
25
+ }
26
+ </style>
27
+ <![endif]-->';
28
+
29
+ $results .= '<div class="instagallery-items" data-source="'.$insta_source.'" id="instagallery-'.$instagal_COUNT.'">';
30
+ foreach ($instaItems as $item) {
31
+
32
+ $img_src = ($gal_cols == 1) ? $item['img_standard'] : $item['img_low'];
33
  $hovered = $gal_imghover ? 'ighover' : '';
34
+ $spacing = $gal_imgspacing ? '' : 'no-spacing';
35
+ $results .= '<div class="ig-item '.$hovered.' '. $spacing .' cols-' . $gal_cols . '" style="width:' . (100 / $gal_cols) . '%;">';
36
 
37
+ $results .= '<a href="' . $item['img_standard'] . '">';
38
+ $results .= '<img src="' . $img_src . '" alt="instagram"/>';
39
  $results .= '</a>';
40
  $results .= '</div>';
41
+
42
  $i ++;
43
  if (($insta_limit != 0) && ($i > $insta_limit))
44
  break;
templates/slider-OLD.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $insta_limit = $av['limit'];
3
+ $sli_effect = $av['sli_effect'];
4
+ $sli_timeout = (int) $av['sli_timeout'];
5
+ $sli_navarrows = $av['sli_navarrows'];
6
+ $sli_dots = $av['sli_dots'];
7
+ $sli_scroll = $av['sli_scroll'];
8
+
9
+ global $instasli_COUNT;
10
+ if(empty($instasli_COUNT))$instasli_COUNT = 0;
11
+ $instasli_COUNT++;
12
+
13
+ // Registering scripts.
14
+ // wp_enqueue_style('swiper', INSGALLERY_URL . '/assests/swiper/swiper.min.css');
15
+ wp_enqueue_script('swiper', INSGALLERY_URL . '/assests/swiper/swiper.jquery.min.js');
16
+
17
+ $i = 1;
18
+
19
+ $results .= '<div class="swiper-container" id="instaslider-'.$instasli_COUNT.'">';
20
+ $results .= '<div class="swiper-wrapper">';
21
+ foreach ($instaItems->items as $item) {
22
+ if (! empty($item->images->standard_resolution->url)) {
23
+ $results .= '<div class="swiper-slide" >';
24
+ $results .= '<img src="' . $item->images->standard_resolution->url . '" /></div>';
25
+ }
26
+ $i ++;
27
+ if (($insta_limit != 0) && ($i > $insta_limit))
28
+ break;
29
+ }
30
+ $results .= '</div>';
31
+ $results .= '<div class="swiper-pagination"></div>';
32
+ if ($sli_navarrows) {
33
+ $results .= '<div class="swiper-button-prev"></div><div class="swiper-button-next"></div>';
34
+ }
35
+ if ($sli_scroll) {
36
+ $results .= '<div class="swiper-scrollbar"></div>';
37
+ }
38
+ $results .= '</div>';
39
+
40
+ $JSISSelector = '#instaslider-'.$instasli_COUNT;
41
+
42
+ $results .= "<script>
43
+ jQuery(document).ready(function () {
44
+ var mySwiper = new Swiper ('$JSISSelector', {
45
+ loop: true,";
46
+ if ($sli_dots) {
47
+ $results .= "pagination: '.swiper-pagination',
48
+ ";
49
+ }
50
+ if ($sli_navarrows) {
51
+ $results .= "nextButton: '.swiper-button-next',
52
+ prevButton: '.swiper-button-prev',";
53
+ }
54
+ if ($sli_scroll) {
55
+ $results .= "scrollbar: '.swiper-scrollbar',";
56
+ }
57
+
58
+ $results .= "effect: '$sli_effect',autoplay: '$sli_timeout',
59
+ });
60
+ });
61
+ </script>";
62
+
63
+ return $results;
templates/slider.php CHANGED
@@ -1,10 +1,12 @@
1
  <?php
2
- $insta_limit = $av['limit'];
3
- $sli_effect = $av['sli_effect'];
4
- $sli_timeout = (int) $av['sli_timeout'];
5
- $sli_navarrows = $av['sli_navarrows'];
6
- $sli_dots = $av['sli_dots'];
7
- $sli_scroll = $av['sli_scroll'];
 
 
8
 
9
  global $instasli_COUNT;
10
  if(empty($instasli_COUNT))$instasli_COUNT = 0;
@@ -16,12 +18,12 @@ wp_enqueue_script('swiper', INSGALLERY_URL . '/assests/swiper/swiper.jquery.min.
16
 
17
  $i = 1;
18
 
19
- $results .= '<div class="swiper-container" id="instaslider-'.$instasli_COUNT.'">';
20
  $results .= '<div class="swiper-wrapper">';
21
- foreach ($instaItems->items as $item) {
22
- if (! empty($item->images->standard_resolution->url)) {
23
  $results .= '<div class="swiper-slide" >';
24
- $results .= '<img src="' . $item->images->standard_resolution->url . '" /></div>';
25
  }
26
  $i ++;
27
  if (($insta_limit != 0) && ($i > $insta_limit))
1
  <?php
2
+ $insta_limit = $IGItem['insta_limit'];
3
+ $sli_effect = $IGItem['insta_sli-effect'];
4
+ $sli_timeout = (int) $IGItem['insta_sli-timeout'];
5
+ $sli_navarrows = $IGItem['insta_sli-navarrows'];
6
+ $sli_dots = $IGItem['insta_sli-dots'];
7
+ $sli_scroll = $IGItem['insta_sli-scroll'];
8
+
9
+ $insta_source = ($IGItem['ig_select_from'] == 'username') ? 'user_'. $IGItem['insta_user'] : 'tag_'. $IGItem['insta_tag'];
10
 
11
  global $instasli_COUNT;
12
  if(empty($instasli_COUNT))$instasli_COUNT = 0;
18
 
19
  $i = 1;
20
 
21
+ $results .= '<div class="swiper-container" data-source="'.$insta_source.'" id="instaslider-'.$instasli_COUNT.'">';
22
  $results .= '<div class="swiper-wrapper">';
23
+ foreach ($instaItems as $item) {
24
+ if (! empty($item['img_standard'])) {
25
  $results .= '<div class="swiper-slide" >';
26
+ $results .= '<img src="' . $item['img_standard'] . '" alt="instagram" /></div>';
27
  }
28
  $i ++;
29
  if (($insta_limit != 0) && ($i > $insta_limit))