Version Description
- Fixed deeplink issue with smartphones. Contributors via wordpress forum @ricksportel
- Added option to block users when searching for hashtag. Sponsored by VirtualStrides.com
- Modified sizes to show square croped and original sizes
- Added new wordpress size only for instagram plugin - regenerating thumbnails might be required.
- Added option to stop Pinterest pinning on images
Download this release
Release Info
Developer | jetonr |
Plugin | Instagram Slider Widget |
Version | 1.3.2 |
Comparing to | |
See all releases |
Code changes from version 1.3.1 to 1.3.2
- assets/js/jr-insta-admin.js +4 -1
- instaram_slider.php +140 -60
- readme.txt +7 -0
assets/js/jr-insta-admin.js
CHANGED
@@ -35,6 +35,7 @@
|
|
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);
|
@@ -45,7 +46,9 @@
|
|
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 |
|
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 |
+
search_for.closest('.jr-container').find('input[id$="blocked_users"]').closest('p').animate({opacity: 'show' , height: 'show'}, 200);
|
39 |
|
40 |
} else {
|
41 |
search_for.closest('.jr-container').find('input[id$="source"]').closest('p').animate({opacity: 'show' , height: 'show'}, 200);
|
46 |
search_for.closest('.jr-container').find('select[id$="images_link"] option[value="user_url"]').animate({opacity: 'show' , height: 'show'}, 200);
|
47 |
search_for.closest('.jr-container').find('select[id$="images_link"] option[value="attachment"]').animate({opacity: 'show' , height: 'show'}, 200);
|
48 |
search_for.closest('.jr-container').find('select[id$="images_link"]').val('image_url');
|
49 |
+
search_for.closest('.jr-container').find('select[id$="description"] option[value="username"]').animate({opacity: 'show' , height: 'show'}, 200);
|
50 |
+
search_for.closest('.jr-container').find('input[id$="blocked_users"]').closest('p').animate({opacity: 'hide' , height: 'hide'}, 200);
|
51 |
+
|
52 |
}
|
53 |
});
|
54 |
|
instaram_slider.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Instagram Slider Widget
|
4 |
-
Plugin URI: http://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/
|
@@ -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
|
@@ -39,6 +39,9 @@ class JR_InstagramSlider extends WP_Widget {
|
|
39 |
)
|
40 |
);
|
41 |
|
|
|
|
|
|
|
42 |
// Shortcode
|
43 |
add_shortcode( 'jr_instagram', array( $this, 'shortcode' ) );
|
44 |
|
@@ -122,7 +125,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
122 |
|
123 |
do_action( 'jr_instagram', $instance );
|
124 |
|
125 |
-
echo $after_widget;
|
126 |
}
|
127 |
|
128 |
/**
|
@@ -139,6 +142,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
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'];
|
@@ -151,6 +155,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
151 |
$instance['image_size'] = $new_instance['image_size'];
|
152 |
$instance['image_link_rel'] = $new_instance['image_link_rel'];
|
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'];
|
@@ -173,6 +178,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
173 |
'search_for' => 'username',
|
174 |
'username' => '',
|
175 |
'hashtag' => '',
|
|
|
176 |
'source' => 'instagram',
|
177 |
'attachment' => 0,
|
178 |
'template' => 'slider',
|
@@ -182,9 +188,10 @@ class JR_InstagramSlider extends WP_Widget {
|
|
182 |
'images_number' => 5,
|
183 |
'columns' => 4,
|
184 |
'refresh_hour' => 5,
|
185 |
-
'image_size' => '
|
186 |
'image_link_rel' => '',
|
187 |
'image_link_class' => '',
|
|
|
188 |
'controls' => 'prev_next',
|
189 |
'animation' => 'slide',
|
190 |
'caption_words' => 100,
|
@@ -252,11 +259,16 @@ class JR_InstagramSlider extends WP_Widget {
|
|
252 |
echo '<span class="jr-description jr-instagram-option '.$insta_option_class.'"><strong>Instagram</strong> can display up to <strong>12</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']; ?>" />
|
@@ -304,29 +316,12 @@ class JR_InstagramSlider extends WP_Widget {
|
|
304 |
</label>
|
305 |
</p>
|
306 |
<p>
|
307 |
-
<?php
|
308 |
-
$image_sizes = array( 'thumbnail', 'medium', 'large' );
|
309 |
-
/*
|
310 |
-
$image_size_options = get_intermediate_image_sizes();
|
311 |
-
if ( is_array( $image_size_options ) && !empty( $image_size_options ) && !$instance['attachment'] ) {
|
312 |
-
$image_sizes = $image_size_options;
|
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=""
|
319 |
-
<?php
|
320 |
-
foreach ( $image_sizes as $image_size_option ) {
|
321 |
-
printf(
|
322 |
-
'<option value="%1$s" %2$s>%3$s</option>',
|
323 |
-
esc_attr( $image_size_option ),
|
324 |
-
selected( $image_size_option, $instance['image_size'], false ),
|
325 |
-
ucfirst( $image_size_option )
|
326 |
-
);
|
327 |
-
}
|
328 |
-
?>
|
329 |
</select>
|
|
|
330 |
</p>
|
331 |
<p>
|
332 |
<label for="<?php echo $this->get_field_id( 'orderby' ); ?>"><strong><?php _e( 'Order by', 'jrinstaslider' ); ?></strong>
|
@@ -382,6 +377,11 @@ class JR_InstagramSlider extends WP_Widget {
|
|
382 |
<span class="jr-description"><?php _e( 'Usefull if you are using jQuery lightbox plugins to open links', 'jrinstaslider' ); ?></span>
|
383 |
|
384 |
</p>
|
|
|
|
|
|
|
|
|
|
|
385 |
</div>
|
386 |
<div class="jr-slider-options <?php if ( 'thumbs' == $instance['template'] || 'thumbs-no-border' == $instance['template'] ) echo 'hidden'; ?>">
|
387 |
<h4 class="jr-advanced-title"><?php _e( 'Advanced Slider Options', 'jrinstaslider'); ?></h4>
|
@@ -483,6 +483,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
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,8 +493,9 @@ class JR_InstagramSlider extends WP_Widget {
|
|
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'] : '
|
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';
|
@@ -509,6 +511,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
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;
|
@@ -525,6 +528,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
525 |
'image_size' => $image_size,
|
526 |
'link_rel' => $image_link_rel,
|
527 |
'link_class' => $image_link_class,
|
|
|
528 |
'caption_words' => $caption_words
|
529 |
);
|
530 |
|
@@ -646,7 +650,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
646 |
if ( 'image_url' == $images_link ) {
|
647 |
$template_args['link_to'] = get_post_meta( $id, 'jr_insta_link', true );
|
648 |
} elseif ( 'user_url' == $images_link ) {
|
649 |
-
$template_args['link_to'] = '
|
650 |
} elseif ( 'local_image_url' == $images_link ) {
|
651 |
$template_args['link_to'] = wp_get_attachment_url( $id );
|
652 |
} elseif ( 'attachment' == $images_link ) {
|
@@ -689,16 +693,14 @@ class JR_InstagramSlider extends WP_Widget {
|
|
689 |
if ( 'image_url' == $images_link ) {
|
690 |
$template_args['link_to'] = $image_data['link'];
|
691 |
} elseif ( 'user_url' == $images_link ) {
|
692 |
-
$template_args['link_to'] = '
|
693 |
} elseif ( 'custom_url' == $images_link ) {
|
694 |
$template_args['link_to'] = $custom_url;
|
695 |
}
|
696 |
|
697 |
-
if ( $image_size == '
|
698 |
$template_args['image'] = $image_data['url_thumbnail'];
|
699 |
-
} elseif
|
700 |
-
$template_args['image'] = $image_data['url_medium'];
|
701 |
-
} elseif( $image_size == 'large' ) {
|
702 |
$template_args['image'] = $image_data['url'];
|
703 |
} else {
|
704 |
$template_args['image'] = $image_data['url'];
|
@@ -719,6 +721,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
719 |
|
720 |
}
|
721 |
|
|
|
722 |
/**
|
723 |
* Function to display Templates styles
|
724 |
*
|
@@ -742,14 +745,15 @@ class JR_InstagramSlider extends WP_Widget {
|
|
742 |
$time = get_post_meta( $attach_id, 'jr_insta_timestamp', true );
|
743 |
$username = get_post_meta( $attach_id, 'jr_insta_username', true );
|
744 |
$image_url = wp_get_attachment_image_src( $attach_id, $args['image_size'] );
|
745 |
-
$image_url = $image_url[0];
|
746 |
}
|
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;
|
754 |
|
755 |
if ( $link_to ) {
|
@@ -783,12 +787,12 @@ class JR_InstagramSlider extends WP_Widget {
|
|
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='
|
787 |
}
|
788 |
|
789 |
if ( $caption != '' && in_array( 'caption', $args['description'] ) ) {
|
790 |
-
$caption = preg_replace( '/@([a-z0-9_]+)/i', ' <a href="
|
791 |
-
$caption = preg_replace( '/\#([a-zA-Z0-9_-]+)/i', ' <a href="https://instagram.com/explore/tags/$1" rel="nofollow" target="_blank">$0</a> ', $caption);
|
792 |
$output .= "<span class='jr-insta-caption'>{$caption}</span>\n";
|
793 |
}
|
794 |
|
@@ -816,12 +820,12 @@ class JR_InstagramSlider extends WP_Widget {
|
|
816 |
}
|
817 |
|
818 |
if ( in_array( 'username', $args['description'] ) && $username ) {
|
819 |
-
$output .= "<span class='jr-insta-username'>by <a rel='nofollow' target='_blank' href='
|
820 |
}
|
821 |
|
822 |
if ( $caption != '' && in_array( 'caption', $args['description'] ) ) {
|
823 |
-
$caption = preg_replace( '/@([a-z0-9_]+)/i', ' <a href="
|
824 |
-
$caption = preg_replace( '/\#([a-zA-Z0-9_-]+)/i', ' <a href="https://instagram.com/explore/tags/$1" rel="nofollow" target="_blank">$0</a> ', $caption);
|
825 |
$output .= "<span class='jr-insta-caption'>{$caption}</span>\n";
|
826 |
}
|
827 |
|
@@ -863,28 +867,33 @@ class JR_InstagramSlider extends WP_Widget {
|
|
863 |
$search_string = $search_for['username'];
|
864 |
} elseif ( isset( $search_for['hashtag'] ) && !empty( $search_for['hashtag'] ) ) {
|
865 |
$search = 'hashtag';
|
866 |
-
$search_string
|
|
|
|
|
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( '
|
886 |
} else {
|
887 |
-
$response = wp_remote_get( '
|
|
|
888 |
}
|
889 |
|
890 |
if ( is_wp_error( $response ) ) {
|
@@ -935,6 +944,13 @@ class JR_InstagramSlider extends WP_Widget {
|
|
935 |
continue;
|
936 |
}
|
937 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
938 |
if ( $current >= $nr_images ) {
|
939 |
break;
|
940 |
}
|
@@ -944,21 +960,12 @@ class JR_InstagramSlider extends WP_Widget {
|
|
944 |
$image_data['user_id'] = $result['owner']['id'];
|
945 |
$image_data['caption'] = isset( $result['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 |
-
|
953 |
-
preg_match( '/([^\/]+$)/', $image_data['url'], $matches );
|
954 |
-
if ( false === strpos( $matches[0], '_7.jpg' ) ) {
|
955 |
-
$image_data['url_medium'] = str_replace( $matches[0], 's320x320/' . $matches[0], $image_data['url'] );
|
956 |
-
$image_data['url_thumbnail'] = str_replace( $matches[0], 's150x150/' . $matches[0], $image_data['url'] );
|
957 |
-
} else {
|
958 |
-
$image_data['url_medium'] = str_replace( '_7.jpg', '_6.jpg', $image_data['url'] );
|
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;
|
@@ -1019,6 +1026,79 @@ class JR_InstagramSlider extends WP_Widget {
|
|
1019 |
return $instaData;
|
1020 |
}
|
1021 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1022 |
/**
|
1023 |
* Updates attachment using the id
|
1024 |
* @param int $attachment_ID
|
@@ -1113,7 +1193,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
1113 |
$form_fields["jr_insta_username"] = array(
|
1114 |
"label" => __( "Instagram Username" ),
|
1115 |
"input" => "html",
|
1116 |
-
"html" => "<span style='line-height:31px'><a target='_blank' href='
|
1117 |
);
|
1118 |
|
1119 |
$instagram_link = get_post_meta( $post->ID, 'jr_insta_link', true );
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Instagram Slider Widget
|
4 |
+
Plugin URI: http://instagram.jrwebstudio.com/
|
5 |
+
Version: 1.3.2
|
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/
|
24 |
*
|
25 |
* @var string
|
26 |
*/
|
27 |
+
const VERSION = '1.3.2';
|
28 |
|
29 |
/**
|
30 |
* Initialize the plugin by registering widget and loading public scripts
|
39 |
)
|
40 |
);
|
41 |
|
42 |
+
// Add new Image Size
|
43 |
+
add_image_size( 'jr_insta_square', 640, 640, true );
|
44 |
+
|
45 |
// Shortcode
|
46 |
add_shortcode( 'jr_instagram', array( $this, 'shortcode' ) );
|
47 |
|
125 |
|
126 |
do_action( 'jr_instagram', $instance );
|
127 |
|
128 |
+
echo $after_widget;
|
129 |
}
|
130 |
|
131 |
/**
|
142 |
$instance['search_for'] = $new_instance['search_for'];
|
143 |
$instance['username'] = $new_instance['username'];
|
144 |
$instance['hashtag'] = $new_instance['hashtag'];
|
145 |
+
$instance['blocked_users'] = $new_instance['blocked_users'];
|
146 |
$instance['source'] = $new_instance['source'];
|
147 |
$instance['attachment'] = $new_instance['attachment'];
|
148 |
$instance['template'] = $new_instance['template'];
|
155 |
$instance['image_size'] = $new_instance['image_size'];
|
156 |
$instance['image_link_rel'] = $new_instance['image_link_rel'];
|
157 |
$instance['image_link_class'] = $new_instance['image_link_class'];
|
158 |
+
$instance['no_pin'] = $new_instance['no_pin'];
|
159 |
$instance['controls'] = $new_instance['controls'];
|
160 |
$instance['animation'] = $new_instance['animation'];
|
161 |
$instance['caption_words'] = $new_instance['caption_words'];
|
178 |
'search_for' => 'username',
|
179 |
'username' => '',
|
180 |
'hashtag' => '',
|
181 |
+
'blocked_users' => '',
|
182 |
'source' => 'instagram',
|
183 |
'attachment' => 0,
|
184 |
'template' => 'slider',
|
188 |
'images_number' => 5,
|
189 |
'columns' => 4,
|
190 |
'refresh_hour' => 5,
|
191 |
+
'image_size' => 'jr_insta_square',
|
192 |
'image_link_rel' => '',
|
193 |
'image_link_class' => '',
|
194 |
+
'no_pin' => 0,
|
195 |
'controls' => 'prev_next',
|
196 |
'animation' => 'slide',
|
197 |
'caption_words' => 100,
|
259 |
echo '<span class="jr-description jr-instagram-option '.$insta_option_class.'"><strong>Instagram</strong> can display up to <strong>12</strong> images for <strong>'. $username .'</strong>!<br> This option will check for new images on Instagram!</span>';
|
260 |
?>
|
261 |
</p>
|
262 |
+
<p class="<?php if ( 'hashtag' != $instance['search_for'] ) echo 'hidden'; ?>">
|
263 |
+
<label for="<?php echo $this->get_field_id( 'blocked_users' ); ?>"><?php _e( 'Block Users', 'jrinstaslider' ); ?>:</label>
|
264 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'blocked_users' ); ?>" name="<?php echo $this->get_field_name( 'blocked_users' ); ?>" value="<?php echo $instance['blocked_users']; ?>" />
|
265 |
+
<span class="jr-description"><?php _e( 'Enter usernames separated by commas whose images you don\'t want to show', 'jrinstaslider' ); ?></span>
|
266 |
+
</p>
|
267 |
<p class="<?php if ( 'instagram' != $instance['source'] || 'username' != $instance['search_for'] ) echo 'hidden'; ?>">
|
268 |
<strong><label for="<?php echo $this->get_field_id( 'attachment' ); ?>"><?php _e( 'Save and Display Images from Media Library:', 'jrinstaslider' ); ?></label></strong>
|
269 |
<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'] ); ?> />
|
270 |
<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>
|
271 |
+
</p>
|
272 |
<p>
|
273 |
<label for="<?php echo $this->get_field_id( 'images_number' ); ?>"><strong><?php _e( 'Number of images to show:', 'jrinstaslider' ); ?></strong>
|
274 |
<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']; ?>" />
|
316 |
</label>
|
317 |
</p>
|
318 |
<p>
|
319 |
+
<label for="<?php echo $this->get_field_id( 'image_size' ); ?>"><strong><?php _e( 'Image format', 'jrinstaslider' ); ?></strong></label>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
320 |
<select class="widefat" id="<?php echo $this->get_field_id( 'image_size' ); ?>" name="<?php echo $this->get_field_name( 'image_size' ); ?>">
|
321 |
+
<option value="jr_insta_square" <?php echo ($instance['image_size'] == 'jr_insta_square') ? ' selected="selected"' : ''; ?>><?php _e( 'Square - Cropped', 'jrinstaslider' ); ?></option>
|
322 |
+
<option value="full" <?php echo ($instance['image_size'] == 'full') ? ' selected="selected"' : ''; ?>><?php _e( 'Original - No Crop', 'jrinstaslider' ); ?></option>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
</select>
|
324 |
+
<span class="jr-description"><?php _e( '<strong>Square - Cropped</strong> - option will show square cropped images in 640x640 pixels. <br/><strong>Original - No Crop</strong> - will display the original user uploaded image size.', 'jrinstaslider' ); ?></span>
|
325 |
</p>
|
326 |
<p>
|
327 |
<label for="<?php echo $this->get_field_id( 'orderby' ); ?>"><strong><?php _e( 'Order by', 'jrinstaslider' ); ?></strong>
|
377 |
<span class="jr-description"><?php _e( 'Usefull if you are using jQuery lightbox plugins to open links', 'jrinstaslider' ); ?></span>
|
378 |
|
379 |
</p>
|
380 |
+
<p>
|
381 |
+
<strong><label for="<?php echo $this->get_field_id( 'no_pin' ); ?>"><?php _e( 'Turn off Pinning:', 'jrinstaslider' ); ?></label></strong>
|
382 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'no_pin' ); ?>" name="<?php echo $this->get_field_name( 'no_pin' ); ?>" type="checkbox" value="1" <?php checked( '1', $instance['no_pin'] ); ?> />
|
383 |
+
<br><span class="jr-description"><?php _e( 'Enable or Disable pinning for Pinterest on all images from this widget!', 'jrinstaslider') ?></span>
|
384 |
+
</p>
|
385 |
</div>
|
386 |
<div class="jr-slider-options <?php if ( 'thumbs' == $instance['template'] || 'thumbs-no-border' == $instance['template'] ) echo 'hidden'; ?>">
|
387 |
<h4 class="jr-advanced-title"><?php _e( 'Advanced Slider Options', 'jrinstaslider'); ?></h4>
|
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;
|
489 |
$template = isset( $args['template'] ) ? $args['template'] : 'slider';
|
493 |
$images_number = isset( $args['images_number'] ) ? absint( $args['images_number'] ) : 5;
|
494 |
$columns = isset( $args['columns'] ) ? absint( $args['columns'] ) : 4;
|
495 |
$refresh_hour = isset( $args['refresh_hour'] ) ? absint( $args['refresh_hour'] ) : 5;
|
496 |
+
$image_size = isset( $args['image_size'] ) ? $args['image_size'] : 'jr_insta_square';
|
497 |
$image_link_rel = isset( $args['image_link_rel'] ) ? $args['image_link_rel'] : '';
|
498 |
+
$no_pin = isset( $args['no_pin'] ) ? $args['no_pin'] : 0;
|
499 |
$image_link_class = isset( $args['image_link_class'] ) ? $args['image_link_class'] : '';
|
500 |
$controls = isset( $args['controls'] ) ? $args['controls'] : 'prev_next';
|
501 |
$animation = isset( $args['animation'] ) ? $args['animation'] : 'slide';
|
511 |
if ( isset ( $args['search_for'] ) && $args['search_for'] == 'hashtag' ) {
|
512 |
$search = 'hashtag';
|
513 |
$search_for['hashtag'] = $hashtag;
|
514 |
+
$search_for['blocked_users'] = $blocked_users;
|
515 |
} else {
|
516 |
$search = 'user';
|
517 |
$search_for['username'] = $username;
|
528 |
'image_size' => $image_size,
|
529 |
'link_rel' => $image_link_rel,
|
530 |
'link_class' => $image_link_class,
|
531 |
+
'no_pin' => $no_pin,
|
532 |
'caption_words' => $caption_words
|
533 |
);
|
534 |
|
650 |
if ( 'image_url' == $images_link ) {
|
651 |
$template_args['link_to'] = get_post_meta( $id, 'jr_insta_link', true );
|
652 |
} elseif ( 'user_url' == $images_link ) {
|
653 |
+
$template_args['link_to'] = 'https://www.instagram.com/' . $username . '/';
|
654 |
} elseif ( 'local_image_url' == $images_link ) {
|
655 |
$template_args['link_to'] = wp_get_attachment_url( $id );
|
656 |
} elseif ( 'attachment' == $images_link ) {
|
693 |
if ( 'image_url' == $images_link ) {
|
694 |
$template_args['link_to'] = $image_data['link'];
|
695 |
} elseif ( 'user_url' == $images_link ) {
|
696 |
+
$template_args['link_to'] = 'https://www.instagram.com/' . $username . '/';
|
697 |
} elseif ( 'custom_url' == $images_link ) {
|
698 |
$template_args['link_to'] = $custom_url;
|
699 |
}
|
700 |
|
701 |
+
if ( $image_size == 'jr_insta_square' ) {
|
702 |
$template_args['image'] = $image_data['url_thumbnail'];
|
703 |
+
} elseif( $image_size == 'full' ) {
|
|
|
|
|
704 |
$template_args['image'] = $image_data['url'];
|
705 |
} else {
|
706 |
$template_args['image'] = $image_data['url'];
|
721 |
|
722 |
}
|
723 |
|
724 |
+
|
725 |
/**
|
726 |
* Function to display Templates styles
|
727 |
*
|
745 |
$time = get_post_meta( $attach_id, 'jr_insta_timestamp', true );
|
746 |
$username = get_post_meta( $attach_id, 'jr_insta_username', true );
|
747 |
$image_url = wp_get_attachment_image_src( $attach_id, $args['image_size'] );
|
748 |
+
$image_url = $image_url[0];
|
749 |
}
|
750 |
|
751 |
$short_caption = wp_trim_words( $caption, 10 );
|
752 |
$short_caption = preg_replace("/[^A-Za-z0-9?! ]/","", $short_caption);
|
753 |
$caption = wp_trim_words( $caption, $args['caption_words'], $more = null );
|
754 |
+
$nopin = ( 1 == $args['no_pin'] ) ? 'nopin="nopin"' : '';
|
755 |
|
756 |
+
$image_src = '<img src="' . $image_url . '" alt="' . $short_caption . '" title="' . $short_caption . '" '. $nopin . '/>';
|
757 |
$image_output = $image_src;
|
758 |
|
759 |
if ( $link_to ) {
|
787 |
$output .= "<span class='jr-insta-time'>{$time} ago</span>\n";
|
788 |
}
|
789 |
if ( in_array( 'username', $args['description'] ) && $username ) {
|
790 |
+
$output .= "<span class='jr-insta-username'>by <a rel='nofollow' href='https://www.instagram.com/{$username}/' target='_blank'>{$username}</a></span>\n";
|
791 |
}
|
792 |
|
793 |
if ( $caption != '' && in_array( 'caption', $args['description'] ) ) {
|
794 |
+
$caption = preg_replace( '/@([a-z0-9_]+)/i', ' <a href="https://www.instagram.com/$1/" rel="nofollow" target="_blank">@$1</a> ', $caption );
|
795 |
+
$caption = preg_replace( '/\#([a-zA-Z0-9_-]+)/i', ' <a href="https://www.instagram.com/explore/tags/$1/" rel="nofollow" target="_blank">$0</a> ', $caption);
|
796 |
$output .= "<span class='jr-insta-caption'>{$caption}</span>\n";
|
797 |
}
|
798 |
|
820 |
}
|
821 |
|
822 |
if ( in_array( 'username', $args['description'] ) && $username ) {
|
823 |
+
$output .= "<span class='jr-insta-username'>by <a rel='nofollow' target='_blank' href='https://www.instagram.com/{$username}/'>{$username}</a></span>\n";
|
824 |
}
|
825 |
|
826 |
if ( $caption != '' && in_array( 'caption', $args['description'] ) ) {
|
827 |
+
$caption = preg_replace( '/@([a-z0-9_]+)/i', ' <a href="https://www.instagram.com/$1/" rel="nofollow" target="_blank">@$1</a> ', $caption );
|
828 |
+
$caption = preg_replace( '/\#([a-zA-Z0-9_-]+)/i', ' <a href="https://www.instagram.com/explore/tags/$1/" rel="nofollow" target="_blank">$0</a> ', $caption);
|
829 |
$output .= "<span class='jr-insta-caption'>{$caption}</span>\n";
|
830 |
}
|
831 |
|
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 |
+
$blocked_users = $search_for['blocked_users'];
|
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 |
$user_opt = (array) get_option( $opt_name );
|
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 |
$user_opt['search'] = $search;
|
886 |
$user_opt['search_string'] = $search_string;
|
887 |
+
$user_opt['blocked_users'] = $blocked_users;
|
888 |
$user_opt['cache_hours'] = $cache_hours;
|
889 |
$user_opt['nr_images'] = $nr_images;
|
890 |
$user_opt['attachment'] = $attachment;
|
891 |
|
892 |
if ( 'user' == $search ) {
|
893 |
+
$response = wp_remote_get( 'https://www.instagram.com/' . trim( $search_string ), array( 'sslverify' => false, 'timeout' => 60 ) );
|
894 |
} else {
|
895 |
+
$response = wp_remote_get( 'https://www.instagram.com/explore/tags/' . trim( $search_string ), array( 'sslverify' => false, 'timeout' => 60 ) );
|
896 |
+
|
897 |
}
|
898 |
|
899 |
if ( is_wp_error( $response ) ) {
|
944 |
continue;
|
945 |
}
|
946 |
|
947 |
+
if ( 'hashtag' == $search ) {
|
948 |
+
if ( in_array( $result['owner']['id'], $blocked_users_array ) ) {
|
949 |
+
$nr_images++;
|
950 |
+
continue;
|
951 |
+
}
|
952 |
+
}
|
953 |
+
|
954 |
if ( $current >= $nr_images ) {
|
955 |
break;
|
956 |
}
|
960 |
$image_data['user_id'] = $result['owner']['id'];
|
961 |
$image_data['caption'] = isset( $result['caption'] ) ? $this->sanitize( $result['caption'] ) : '';
|
962 |
$image_data['id'] = $result['id'];
|
963 |
+
$image_data['link'] = 'https://www.instagram.com/p/'. $result['code'] . '/';
|
964 |
$image_data['popularity'] = (int) ( $result['comments']['count'] ) + ( $result['likes']['count'] );
|
965 |
$image_data['timestamp'] = (float) $result['date'];
|
966 |
$image_data['url'] = $result['display_src'];
|
967 |
+
$image_data['url_thumbnail'] = $result['thumbnail_src'];
|
968 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
969 |
if ( ( $search == 'hashtag' ) || ( $search == 'user' && !$attachment ) ) {
|
970 |
|
971 |
$instaData[] = $image_data;
|
1026 |
return $instaData;
|
1027 |
}
|
1028 |
|
1029 |
+
|
1030 |
+
/**
|
1031 |
+
* Get Instagram Ids from Usernames into array
|
1032 |
+
* @param string $usernames Comma separated string with instagram users
|
1033 |
+
* @return array An array with instagram ids
|
1034 |
+
*/
|
1035 |
+
private function get_ids_from_usernames( $usernames ) {
|
1036 |
+
|
1037 |
+
$users = explode( ',', trim( $usernames ) );
|
1038 |
+
$user_ids = (array) get_transient( 'jr_insta_user_ids' );
|
1039 |
+
$return_ids = array();
|
1040 |
+
|
1041 |
+
if ( is_array( $users ) && !empty( $users ) ) {
|
1042 |
+
|
1043 |
+
foreach ( $users as $user ) {
|
1044 |
+
|
1045 |
+
if ( isset( $user_ids[$user] ) ) {
|
1046 |
+
continue;
|
1047 |
+
}
|
1048 |
+
|
1049 |
+
$response = wp_remote_get( 'https://www.instagram.com/' . trim( $user ), array( 'sslverify' => false, 'timeout' => 60 ) );
|
1050 |
+
|
1051 |
+
if ( is_wp_error( $response ) ) {
|
1052 |
+
|
1053 |
+
return $response->get_error_message();
|
1054 |
+
}
|
1055 |
+
|
1056 |
+
if ( $response['response']['code'] == 200 ) {
|
1057 |
+
|
1058 |
+
$json = str_replace( 'window._sharedData = ', '', strstr( $response['body'], 'window._sharedData = ' ) );
|
1059 |
+
|
1060 |
+
// Compatibility for version of php where strstr() doesnt accept third parameter
|
1061 |
+
if ( version_compare( PHP_VERSION, '5.3.0', '>=' ) ) {
|
1062 |
+
$json = strstr( $json, '</script>', true );
|
1063 |
+
} else {
|
1064 |
+
$json = substr( $json, 0, strpos( $json, '</script>' ) );
|
1065 |
+
}
|
1066 |
+
|
1067 |
+
$json = rtrim( $json, ';' );
|
1068 |
+
|
1069 |
+
// Function json_last_error() is not available before PHP * 5.3.0 version
|
1070 |
+
if ( function_exists( 'json_last_error' ) ) {
|
1071 |
+
|
1072 |
+
( $results = json_decode( $json, true ) ) && json_last_error() == JSON_ERROR_NONE;
|
1073 |
+
|
1074 |
+
} else {
|
1075 |
+
|
1076 |
+
$results = json_decode( $json, true );
|
1077 |
+
}
|
1078 |
+
|
1079 |
+
if ( $results && is_array( $results ) ) {
|
1080 |
+
|
1081 |
+
$user_id = isset( $results['entry_data']['ProfilePage'][0]['user']['id'] ) ? $results['entry_data']['ProfilePage'][0]['user']['id'] : false;
|
1082 |
+
|
1083 |
+
if ( $user_id ) {
|
1084 |
+
|
1085 |
+
$user_ids[$user] = $user_id;
|
1086 |
+
|
1087 |
+
set_transient( 'jr_insta_user_ids', $user_ids );
|
1088 |
+
}
|
1089 |
+
}
|
1090 |
+
}
|
1091 |
+
}
|
1092 |
+
}
|
1093 |
+
|
1094 |
+
foreach ( $users as $user ) {
|
1095 |
+
$return_ids[] = $user_ids[$user];
|
1096 |
+
}
|
1097 |
+
|
1098 |
+
return $return_ids;
|
1099 |
+
}
|
1100 |
+
|
1101 |
+
|
1102 |
/**
|
1103 |
* Updates attachment using the id
|
1104 |
* @param int $attachment_ID
|
1193 |
$form_fields["jr_insta_username"] = array(
|
1194 |
"label" => __( "Instagram Username" ),
|
1195 |
"input" => "html",
|
1196 |
+
"html" => "<span style='line-height:31px'><a target='_blank' href='https://www.instagram.com/{$instagram_username}/'>{$instagram_username}</a></span>"
|
1197 |
);
|
1198 |
|
1199 |
$instagram_link = get_post_meta( $post->ID, 'jr_insta_link', true );
|
readme.txt
CHANGED
@@ -43,6 +43,13 @@ 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.1 =
|
47 |
* Fixed issue when no images were shown due to instagram recent changes.
|
48 |
* Caption fix when no caption in image
|
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
|
49 |
+
* Modified sizes to show square croped and original sizes
|
50 |
+
* Added new wordpress size only for instagram plugin - regenerating thumbnails might be required.
|
51 |
+
* Added option to stop Pinterest pinning on images
|
52 |
+
|
53 |
= 1.3.1 =
|
54 |
* Fixed issue when no images were shown due to instagram recent changes.
|
55 |
* Caption fix when no caption in image
|