Version Description
- Fixed notification error message.
Download this release
Release Info
Developer | jetonr |
Plugin | Instagram Slider Widget |
Version | 1.3.3 |
Comparing to | |
See all releases |
Code changes from version 1.3.2 to 1.3.3
- instaram_slider.php +64 -27
- readme.txt +7 -2
instaram_slider.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/*
|
3 |
Plugin Name: Instagram Slider Widget
|
4 |
Plugin URI: http://instagram.jrwebstudio.com/
|
5 |
-
Version: 1.3.
|
6 |
-
Description: Instagram Slider Widget is a responsive slider widget that shows 12 latest images from a public Instagram user.
|
7 |
Author: jetonr
|
8 |
Author URI: http://jrwebstudio.com/
|
9 |
License: GPLv2 or later
|
@@ -24,7 +24,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
24 |
*
|
25 |
* @var string
|
26 |
*/
|
27 |
-
const VERSION = '1.3.
|
28 |
|
29 |
/**
|
30 |
* Initialize the plugin by registering widget and loading public scripts
|
@@ -482,7 +482,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
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 |
$blocked_users = isset( $args['blocked_users'] ) && !empty( $args['blocked_users'] ) ? $args['blocked_users'] : false;
|
487 |
$source = isset( $args['source'] ) && !empty( $args['source'] ) ? $args['source'] : 'instagram';
|
488 |
$attachment = isset( $args['attachment'] ) ? true : false;
|
@@ -849,8 +849,34 @@ class JR_InstagramSlider extends WP_Widget {
|
|
849 |
}
|
850 |
|
851 |
return $output;
|
852 |
-
}
|
853 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
854 |
/**
|
855 |
* Stores the fetched data from instagram in WordPress DB using transients
|
856 |
*
|
@@ -862,32 +888,39 @@ class JR_InstagramSlider extends WP_Widget {
|
|
862 |
*/
|
863 |
private function instagram_data( $search_for, $cache_hours, $nr_images, $attachment ) {
|
864 |
|
|
|
865 |
if ( isset( $search_for['username'] ) && !empty( $search_for['username'] ) ) {
|
866 |
$search = 'user';
|
867 |
$search_string = $search_for['username'];
|
868 |
} elseif ( isset( $search_for['hashtag'] ) && !empty( $search_for['hashtag'] ) ) {
|
869 |
$search = 'hashtag';
|
870 |
$search_string = $search_for['hashtag'];
|
871 |
-
$
|
872 |
-
$blocked_users_array = $this->get_ids_from_usernames( $blocked_users );
|
873 |
} else {
|
874 |
return __( 'Nothing to search for', 'jrinstaslider');
|
875 |
}
|
876 |
|
877 |
-
|
878 |
$opt_name = 'jr_insta_' . md5( $search . '_' . $search_string );
|
879 |
$instaData = get_transient( $opt_name );
|
880 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
881 |
|
882 |
-
if ( false === $instaData || $user_opt['blocked_users'] != $blocked_users || $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 ) {
|
883 |
-
|
884 |
$instaData = array();
|
885 |
-
$
|
886 |
-
$
|
887 |
-
$
|
888 |
-
$
|
889 |
-
$
|
890 |
-
$
|
891 |
|
892 |
if ( 'user' == $search ) {
|
893 |
$response = wp_remote_get( 'https://www.instagram.com/' . trim( $search_string ), array( 'sslverify' => false, 'timeout' => 60 ) );
|
@@ -936,7 +969,9 @@ class JR_InstagramSlider extends WP_Widget {
|
|
936 |
if ( empty( $entry_data ) ) {
|
937 |
return __( 'No images found', 'jrinstaslider');
|
938 |
}
|
939 |
-
|
|
|
|
|
940 |
foreach ( $entry_data as $current => $result ) {
|
941 |
|
942 |
if ( $result['is_video'] == true ) {
|
@@ -972,17 +1007,17 @@ class JR_InstagramSlider extends WP_Widget {
|
|
972 |
|
973 |
} else {
|
974 |
|
975 |
-
if ( isset( $
|
976 |
|
977 |
-
if ( is_string( get_post_status( $
|
978 |
|
979 |
-
$this->update_wp_attachment( $
|
980 |
|
981 |
-
$instaData[$image_data['id']] = $
|
982 |
|
983 |
} else {
|
984 |
|
985 |
-
$
|
986 |
}
|
987 |
|
988 |
} else {
|
@@ -991,7 +1026,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
991 |
|
992 |
if ( $id && is_numeric( $id ) ) {
|
993 |
|
994 |
-
$
|
995 |
|
996 |
$instaData[$image_data['id']] = $id;
|
997 |
|
@@ -1014,7 +1049,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
1014 |
|
1015 |
} // end -> $response['response']['code'] === 200 )
|
1016 |
|
1017 |
-
update_option( $opt_name, $
|
1018 |
|
1019 |
if ( is_array( $instaData ) && !empty( $instaData ) ) {
|
1020 |
|
@@ -1092,7 +1127,9 @@ class JR_InstagramSlider extends WP_Widget {
|
|
1092 |
}
|
1093 |
|
1094 |
foreach ( $users as $user ) {
|
1095 |
-
|
|
|
|
|
1096 |
}
|
1097 |
|
1098 |
return $return_ids;
|
2 |
/*
|
3 |
Plugin Name: Instagram Slider Widget
|
4 |
Plugin URI: http://instagram.jrwebstudio.com/
|
5 |
+
Version: 1.3.3
|
6 |
+
Description: Instagram Slider Widget is a responsive slider widget that shows 12 latest images from a public Instagram user and up to 18 images from a hashtag.
|
7 |
Author: jetonr
|
8 |
Author URI: http://jrwebstudio.com/
|
9 |
License: GPLv2 or later
|
24 |
*
|
25 |
* @var string
|
26 |
*/
|
27 |
+
const VERSION = '1.3.3';
|
28 |
|
29 |
/**
|
30 |
* Initialize the plugin by registering widget and loading public scripts
|
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'] ) ? str_replace( '#', '', $args['hashtag'] ) : false;
|
486 |
$blocked_users = isset( $args['blocked_users'] ) && !empty( $args['blocked_users'] ) ? $args['blocked_users'] : false;
|
487 |
$source = isset( $args['source'] ) && !empty( $args['source'] ) ? $args['source'] : 'instagram';
|
488 |
$attachment = isset( $args['attachment'] ) ? true : false;
|
849 |
}
|
850 |
|
851 |
return $output;
|
852 |
+
}
|
853 |
+
|
854 |
+
/**
|
855 |
+
* Trigger refresh for new data
|
856 |
+
* @param bolean $instaData
|
857 |
+
* @param array $old_args
|
858 |
+
* @param array $new_args
|
859 |
+
* @return bolean
|
860 |
+
*/
|
861 |
+
private function trigger_refresh_data( $instaData, $old_args, $new_args ) {
|
862 |
+
|
863 |
+
$trigger = 0;
|
864 |
+
|
865 |
+
if ( false === $instaData ) {
|
866 |
+
$trigger = 1;
|
867 |
+
}
|
868 |
+
|
869 |
+
if ( is_array( $old_args ) && is_array( $new_args ) && array_diff( $old_args, $new_args ) !== array_diff( $new_args, $old_args ) ) {
|
870 |
+
$trigger = 1;
|
871 |
+
}
|
872 |
+
|
873 |
+
if ( $trigger == 1 ) {
|
874 |
+
return true;
|
875 |
+
}
|
876 |
+
|
877 |
+
return false;
|
878 |
+
}
|
879 |
+
|
880 |
/**
|
881 |
* Stores the fetched data from instagram in WordPress DB using transients
|
882 |
*
|
888 |
*/
|
889 |
private function instagram_data( $search_for, $cache_hours, $nr_images, $attachment ) {
|
890 |
|
891 |
+
$blocked_users = isset( $search_for['blocked_users'] ) && !empty( $search_for['blocked_users'] ) ? $search_for['blocked_users'] : false;
|
892 |
if ( isset( $search_for['username'] ) && !empty( $search_for['username'] ) ) {
|
893 |
$search = 'user';
|
894 |
$search_string = $search_for['username'];
|
895 |
} elseif ( isset( $search_for['hashtag'] ) && !empty( $search_for['hashtag'] ) ) {
|
896 |
$search = 'hashtag';
|
897 |
$search_string = $search_for['hashtag'];
|
898 |
+
$blocked_users_array = $blocked_users ? $this->get_ids_from_usernames( $blocked_users ) : array();
|
|
|
899 |
} else {
|
900 |
return __( 'Nothing to search for', 'jrinstaslider');
|
901 |
}
|
902 |
|
|
|
903 |
$opt_name = 'jr_insta_' . md5( $search . '_' . $search_string );
|
904 |
$instaData = get_transient( $opt_name );
|
905 |
+
$old_opts = (array) get_option( $opt_name );
|
906 |
+
$new_opts = array(
|
907 |
+
'search' => $search,
|
908 |
+
'search_string' => $search_string,
|
909 |
+
'blocked_users' => $blocked_users,
|
910 |
+
'cache_hours' => $cache_hours,
|
911 |
+
'nr_images' => $nr_images,
|
912 |
+
'attachment' => $attachment
|
913 |
+
);
|
914 |
+
|
915 |
+
if ( true === $this->trigger_refresh_data( $instaData, $old_opts, $new_opts ) ) {
|
916 |
|
|
|
|
|
917 |
$instaData = array();
|
918 |
+
$old_opts['search'] = $search;
|
919 |
+
$old_opts['search_string'] = $search_string;
|
920 |
+
$old_opts['blocked_users'] = $blocked_users;
|
921 |
+
$old_opts['cache_hours'] = $cache_hours;
|
922 |
+
$old_opts['nr_images'] = $nr_images;
|
923 |
+
$old_opts['attachment'] = $attachment;
|
924 |
|
925 |
if ( 'user' == $search ) {
|
926 |
$response = wp_remote_get( 'https://www.instagram.com/' . trim( $search_string ), array( 'sslverify' => false, 'timeout' => 60 ) );
|
969 |
if ( empty( $entry_data ) ) {
|
970 |
return __( 'No images found', 'jrinstaslider');
|
971 |
}
|
972 |
+
|
973 |
+
$count = count($entry_data);
|
974 |
+
|
975 |
foreach ( $entry_data as $current => $result ) {
|
976 |
|
977 |
if ( $result['is_video'] == true ) {
|
1007 |
|
1008 |
} else {
|
1009 |
|
1010 |
+
if ( isset( $old_opts['saved_images'][$image_data['id']] ) ) {
|
1011 |
|
1012 |
+
if ( is_string( get_post_status( $old_opts['saved_images'][$image_data['id']] ) ) ) {
|
1013 |
|
1014 |
+
$this->update_wp_attachment( $old_opts['saved_images'][$image_data['id']], $image_data );
|
1015 |
|
1016 |
+
$instaData[$image_data['id']] = $old_opts['saved_images'][$image_data['id']];
|
1017 |
|
1018 |
} else {
|
1019 |
|
1020 |
+
$old_opts['deleted_images'][$image_data['id']] = $image_data['url_thumbnail'];
|
1021 |
}
|
1022 |
|
1023 |
} else {
|
1026 |
|
1027 |
if ( $id && is_numeric( $id ) ) {
|
1028 |
|
1029 |
+
$old_opts['saved_images'][$image_data['id']] = $id;
|
1030 |
|
1031 |
$instaData[$image_data['id']] = $id;
|
1032 |
|
1049 |
|
1050 |
} // end -> $response['response']['code'] === 200 )
|
1051 |
|
1052 |
+
update_option( $opt_name, $old_opts );
|
1053 |
|
1054 |
if ( is_array( $instaData ) && !empty( $instaData ) ) {
|
1055 |
|
1127 |
}
|
1128 |
|
1129 |
foreach ( $users as $user ) {
|
1130 |
+
if ( isset( $user_ids[$user] ) ) {
|
1131 |
+
$return_ids[] = $user_ids[$user];
|
1132 |
+
}
|
1133 |
}
|
1134 |
|
1135 |
return $return_ids;
|
readme.txt
CHANGED
@@ -7,10 +7,12 @@ Tested up to: 4.5.2
|
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
-
Instagram Slider Widget is a responsive slider widget that shows 12 latest images from a public instagram user or hashtag.
|
11 |
|
12 |
== Description ==
|
13 |
-
|
|
|
|
|
14 |
= Features =
|
15 |
* Images from instagram are imported as wordpress attachments
|
16 |
* Display Images in Slider or Thumbnails
|
@@ -43,6 +45,9 @@ 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.3.2 =
|
47 |
* Fixed deeplink issue with smartphones. Contributors via wordpress forum @ricksportel
|
48 |
* Added option to block users when searching for hashtag. Sponsored by VirtualStrides.com
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
+
Instagram Slider Widget is a responsive slider widget that shows 12 latest images from a public instagram user or up to 18 images from a hashtag.
|
11 |
|
12 |
== Description ==
|
13 |
+
= Instagram Slider Widget is a responsive slider widget that shows 12 latest images from a public instagram user or up to 18 images from a hashtag. =
|
14 |
+
|
15 |
+
|
16 |
= Features =
|
17 |
* Images from instagram are imported as wordpress attachments
|
18 |
* Display Images in Slider or Thumbnails
|
45 |
3. Backend Configuration
|
46 |
|
47 |
== Changelog ==
|
48 |
+
= 1.3.3 =
|
49 |
+
* Fixed notification error message.
|
50 |
+
|
51 |
= 1.3.2 =
|
52 |
* Fixed deeplink issue with smartphones. Contributors via wordpress forum @ricksportel
|
53 |
* Added option to block users when searching for hashtag. Sponsored by VirtualStrides.com
|