BlossomThemes Social Feed - Version 1.0.1

Version Description

Download this release

Release Info

Developer blossomthemes
Plugin Icon 128x128 BlossomThemes Social Feed
Version 1.0.1
Comparing to
See all releases

Code changes from version 1.0.0 to 1.0.1

README.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: blossomthemes
3
  Donate link: https://blossomthemes.com
4
  Tags: comments, spam
5
  Requires at least: 4.3
6
- Tested up to: 4.8.1
7
- Stable tag: 1.0.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -46,3 +46,6 @@ If you do not enter the Instagram username in the widget, the username assigned
46
 
47
  = 1.0.0 =
48
  * Initial release
 
 
 
3
  Donate link: https://blossomthemes.com
4
  Tags: comments, spam
5
  Requires at least: 4.3
6
+ Tested up to: 4.9
7
+ Stable tag: 1.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
46
 
47
  = 1.0.0 =
48
  * Initial release
49
+
50
+ = 1.0.1 =
51
+ * Compatibility tested
admin/class-blossomthemes-instagram-feed-admin.php CHANGED
@@ -129,32 +129,4 @@ class Blossomthemes_Instagram_Feed_Admin {
129
  $blossom_themes_settings = new BlossomThemes_Instagram_Feed_Settings();
130
  $blossom_themes_settings->blossomthemes_instagram_feed_backend_settings();
131
  }
132
-
133
- //save settings
134
- function blossomthemes_instagram_feed_save_input()
135
- {
136
- if( isset( $_POST['submit'] ) && current_user_can( 'administrator' ) )
137
- {
138
- $nonce = $_POST['blossomthemes-instagram-feed-nonce'];
139
- if ( wp_verify_nonce( $nonce, 'blossomthemes-instagram-feed-nonce' ) ) {
140
- $option = get_option( 'blossomthemes_instagram_feed_settings', true );
141
- $array = $_POST['blossomthemes_instagram_feed_settings'];
142
- if(is_array($array))
143
- {
144
- $arr = array_merge( $option, $array );
145
- if (is_array($arr))
146
- {
147
- $arrays = $arr;
148
- $array = array();
149
- if (!empty( $arrays ) && is_array( $arrays ) ) {
150
- foreach( $arrays as $key => $value ) {
151
- $array[] = filter_var( $value, FILTER_SANITIZE_STRING );
152
- }
153
- }
154
- }
155
- add_option( 'blossomthemes_instagram_feed_settings', $array );
156
- }
157
- }
158
- }
159
- }
160
  }
129
  $blossom_themes_settings = new BlossomThemes_Instagram_Feed_Settings();
130
  $blossom_themes_settings->blossomthemes_instagram_feed_backend_settings();
131
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  }
blossomthemes-instagram-feed.php CHANGED
@@ -16,7 +16,7 @@
16
  * Plugin Name: BlossomThemes Instagram Feed
17
  * Plugin URI: https://wordpress.org/plugins/blossomthemes-instagram-feed
18
  * Description: Show instagram feed on your website using shortcode and widget.
19
- * Version: 1.0.0
20
  * Author: blossomthemes
21
  * Author URI: https://blossomthemes.com
22
  * License: GPL-2.0+
16
  * Plugin Name: BlossomThemes Instagram Feed
17
  * Plugin URI: https://wordpress.org/plugins/blossomthemes-instagram-feed
18
  * Description: Show instagram feed on your website using shortcode and widget.
19
+ * Version: 1.0.1
20
  * Author: blossomthemes
21
  * Author URI: https://blossomthemes.com
22
  * License: GPL-2.0+
includes/class-blossomthemes-instagram-feed-shortcodes.php CHANGED
@@ -16,11 +16,18 @@ class BlossomThemes_Instagram_Feed_Shortcodes
16
  function blossomthemes_instagram_feed_sc(){
17
  ob_start();
18
  $options = get_option( 'blossomthemes_instagram_feed_settings', true );
 
 
 
 
 
 
19
  $obj = new InstagramSpider;
20
  $photos = absint($options['photos']);
21
  $photos_row = isset( $options['photos_row'] ) ? esc_attr( $options['photos_row'] ) :'5';
22
  $instaUrl = 'https://www.instagram.com/';
23
  $instaUrl .= $options['username'];
 
24
  $instaItems = $obj->getUserItems($options['username']);
25
  $profile_link_text = isset( $options['follow_me'] ) ? esc_attr( $options['follow_me'] ):'Follow Me!';
26
  echo '<ul class="popup-gallery photos-'.$photos_row.'">';
16
  function blossomthemes_instagram_feed_sc(){
17
  ob_start();
18
  $options = get_option( 'blossomthemes_instagram_feed_settings', true );
19
+
20
+ if( !isset( $options['username'] ) || $options['username'] == '' )
21
+ {
22
+ return;
23
+ }
24
+
25
  $obj = new InstagramSpider;
26
  $photos = absint($options['photos']);
27
  $photos_row = isset( $options['photos_row'] ) ? esc_attr( $options['photos_row'] ) :'5';
28
  $instaUrl = 'https://www.instagram.com/';
29
  $instaUrl .= $options['username'];
30
+
31
  $instaItems = $obj->getUserItems($options['username']);
32
  $profile_link_text = isset( $options['follow_me'] ) ? esc_attr( $options['follow_me'] ):'Follow Me!';
33
  echo '<ul class="popup-gallery photos-'.$photos_row.'">';
includes/vendor/InstagramSpider.php CHANGED
@@ -54,6 +54,29 @@ class InstagramSpider
54
  }
55
  }
56
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  return $items;
58
  }
59
 
@@ -100,30 +123,47 @@ class InstagramSpider
100
  * @param string $url
101
  * @return string
102
  */
103
- protected function ig_spider($url = '')
104
  {
105
  if (empty($url) || (! filter_var($url, FILTER_VALIDATE_URL))) {
106
  $this->messages[] = 'Please provide a Valid URL';
107
  return;
108
  }
109
  $instaItems = '';
110
- if (function_exists('curl_version')) {
111
- $ch = curl_init();
112
- curl_setopt($ch, CURLOPT_URL, $url);
113
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
114
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
115
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
116
- $contents = curl_exec($ch);
117
- if (curl_error($ch)) {
118
- $this->messages[] = 'error: ' . curl_error($ch);
 
 
119
  }
120
- curl_close($ch);
121
- $instaItems = $contents;
122
- } else {
123
- if (ini_get('allow_url_fopen')) {
124
- $instaItems = @file_get_contents($url);
 
 
 
 
 
 
 
 
 
 
 
125
  } else {
126
- $this->messages[] = 'Your server does\'t have enabled the required extensions/functions.';
 
 
 
 
127
  }
128
  }
129
  return $instaItems;
54
  }
55
  }
56
  }
57
+
58
+ if(empty($items)){
59
+ $inURL = $this->instagram . $username . '/?__a=1';
60
+ $instaRes = $this->ig_spider($inURL);
61
+ $instaRes = @json_decode($instaRes);
62
+ $items = array();
63
+ if (isset($instaRes->user->media->nodes)) {
64
+ $instaItems = $instaRes->user->media->nodes;
65
+
66
+ if (! empty($instaItems) && is_array($instaItems)) {
67
+ foreach ($instaItems as $res) {
68
+ $items[] = array(
69
+ 'img_standard' => $res->display_src,
70
+ 'img_low' => $res->thumbnail_resources[4]->src,
71
+ 'img_thumb' => $res->thumbnail_resources[0]->src,
72
+ 'likes' => $res->likes->count,
73
+ 'comments' => $res->comments->count,
74
+ 'caption' => isset($res->caption) ? htmlspecialchars($res->caption) : ''
75
+ );
76
+ }
77
+ }
78
+ }
79
+ }
80
  return $items;
81
  }
82
 
123
  * @param string $url
124
  * @return string
125
  */
126
+ protected function ig_spider($url = '')
127
  {
128
  if (empty($url) || (! filter_var($url, FILTER_VALIDATE_URL))) {
129
  $this->messages[] = 'Please provide a Valid URL';
130
  return;
131
  }
132
  $instaItems = '';
133
+
134
+ // get results if script executed in WP
135
+ if (function_exists('wp_remote_request')) {
136
+ $result = wp_remote_request($url);
137
+ if (is_wp_error($result)) {
138
+ return;
139
+ // $this->messages[] = 'WP Error: ' . end($result->get_error_messages());
140
+ } else {
141
+ if (! empty($result['body'])) {
142
+ $instaItems = $result['body'];
143
+ }
144
  }
145
+ }
146
+
147
+ if (empty($instaItems)) { // continue via PHP
148
+
149
+ if (function_exists('curl_version')) {
150
+ $ch = curl_init();
151
+ curl_setopt($ch, CURLOPT_URL, $url);
152
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
153
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
154
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
155
+ $contents = curl_exec($ch);
156
+ if (curl_error($ch)) {
157
+ $this->messages[] = 'error: ' . curl_error($ch);
158
+ }
159
+ curl_close($ch);
160
+ $instaItems = $contents;
161
  } else {
162
+ if (ini_get('allow_url_fopen')) {
163
+ $instaItems = @file_get_contents($url);
164
+ } else {
165
+ $this->messages[] = 'Your server does\'t have enabled the required extensions/functions.';
166
+ }
167
  }
168
  }
169
  return $instaItems;
includes/widgets/widget-blossomthemes-instagram-feed.php CHANGED
@@ -45,7 +45,7 @@ class BlossomThemes_Instagram_Widget extends WP_Widget {
45
  $username = empty( $instance['username'] ) ? $options['username'] : $instance['username'];
46
  $profile_link = 'https://www.instagram.com/'.$username ;
47
  $profile_link_text = empty( $instance['profile_link_text'] ) ? 'Follow Me!' : $instance['profile_link_text'];
48
- $meta = $instance['meta'] ? 'true' : 'false';
49
 
50
  echo $args['before_widget'];
51
 
45
  $username = empty( $instance['username'] ) ? $options['username'] : $instance['username'];
46
  $profile_link = 'https://www.instagram.com/'.$username ;
47
  $profile_link_text = empty( $instance['profile_link_text'] ) ? 'Follow Me!' : $instance['profile_link_text'];
48
+ $meta = isset( $instance['meta'] ) ? 'true' : 'false';
49
 
50
  echo $args['before_widget'];
51