Version Description
- Fixed the issue where duplicate images were being inserted into Media Library
- Added a button in widget to remove previously created duplicate images
- Simplified the options to save images into media library
- Added an option to show backlink to help plugin development
Download this release
Release Info
Developer | jetonr |
Plugin | Instagram Slider Widget |
Version | 1.4.0 |
Comparing to | |
See all releases |
Code changes from version 1.3.3 to 1.4.0
- assets/css/instag-slider.css +1 -1
- assets/css/jr-insta-admin.css +11 -11
- assets/js/jr-insta-admin.js +18 -58
- instaram_slider.php +423 -299
- readme.txt +14 -8
assets/css/instag-slider.css
CHANGED
@@ -31,7 +31,7 @@
|
|
31 |
.pllexislider .pllex-direction-nav li a { line-height: normal; overflow: hidden; display: block; border: 0 }
|
32 |
.pllexislider .pllex-direction-nav li a:focus { outline: 0 }
|
33 |
.pllexislider .pllex-direction-nav li:first-child { float: left; margin-right: 0; border-left: 0; border-right: 1px solid gray; }
|
34 |
-
.pllexislider .pllex-direction-nav li { list-style:none; float: right; margin: 0; border-right: 0; border-left: 1px solid #1e1e1e; }
|
35 |
.pllexislider .pllex-direction-nav .pllex-next:before,
|
36 |
.pllexislider .pllex-direction-nav .pllex-prev:before { font-family: Arial,Helvetica,sans-serif; display: inline-block; padding: 0 4px 1px; speak: none; color: #fff; font-size: 18px; text-shadow: 0 2px 0 rgba(0, 0, 0, 1); }
|
37 |
.pllexislider .pllex-direction-nav .pllex-next:before { content: '\25BA'; }
|
31 |
.pllexislider .pllex-direction-nav li a { line-height: normal; overflow: hidden; display: block; border: 0 }
|
32 |
.pllexislider .pllex-direction-nav li a:focus { outline: 0 }
|
33 |
.pllexislider .pllex-direction-nav li:first-child { float: left; margin-right: 0; border-left: 0; border-right: 1px solid gray; }
|
34 |
+
.pllexislider .pllex-direction-nav li { list-style:none; float: right; margin: 0; border-right: 0; border-left: 1px solid #1e1e1e; padding: 0; border-top: 0; border-bottom: 0; }
|
35 |
.pllexislider .pllex-direction-nav .pllex-next:before,
|
36 |
.pllexislider .pllex-direction-nav .pllex-prev:before { font-family: Arial,Helvetica,sans-serif; display: inline-block; padding: 0 4px 1px; speak: none; color: #fff; font-size: 18px; text-shadow: 0 2px 0 rgba(0, 0, 0, 1); }
|
37 |
.pllexislider .pllex-direction-nav .pllex-next:before { content: '\25BA'; }
|
assets/css/jr-insta-admin.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
.jr-container .donate { padding: 5px; display: inline-block; position: relative; color: #
|
2 |
.jr-container .donate a { outline: 0; cursor: pointer }
|
3 |
-
.jr-container .donate span:before { color: #
|
4 |
.jr-container .pressthis a, .jr-container .pressthis-bookmarklet a,
|
5 |
.jr-container .pressthis a:active, .jr-container .pressthis-bookmarklet a:active,
|
6 |
.jr-container .pressthis a:focus, .jr-container .pressthis-bookmarklet a:focus,
|
@@ -18,12 +18,12 @@
|
|
18 |
.jr-container .jr-description { color: #777; font-size: smaller; clear:both; display:block; margin-top: 5px;}
|
19 |
.jr-container .jr-description.hide-media-library, .jr-container .jr-description.hide-instagram { display: none }
|
20 |
|
21 |
-
.jr-container .
|
22 |
-
.jr-container .
|
23 |
-
.jr-container .
|
24 |
-
.jr-container .
|
25 |
-
.jr-container
|
26 |
-
.jr-container
|
27 |
-
.jr-container
|
28 |
-
.jr-container .
|
29 |
-
.jr-container .
|
1 |
+
.jr-container .donate { padding: 5px 15px 10px; display: inline-block; position: relative; color: #000; background: #ffd751; -webkit-border-radius: 5px; border-radius: 5px; border: 1px solid #b4b4b4; font-weight: bold; font-size: 14px; text-decoration: none; }
|
2 |
.jr-container .donate a { outline: 0; cursor: pointer }
|
3 |
+
.jr-container .donate span:before { color: #ce1f00; font: 400 20px/1 dashicons; font-family: dashicons; font-size: 24px; font-style: normal; font-variant: normal; font-weight: 400; font-stretch: normal; line-height: 1; content: '\f524'; position: relative; display: inline-block; top: 4px; margin-right: 4px; }
|
4 |
.jr-container .pressthis a, .jr-container .pressthis-bookmarklet a,
|
5 |
.jr-container .pressthis a:active, .jr-container .pressthis-bookmarklet a:active,
|
6 |
.jr-container .pressthis a:focus, .jr-container .pressthis-bookmarklet a:focus,
|
18 |
.jr-container .jr-description { color: #777; font-size: smaller; clear:both; display:block; margin-top: 5px;}
|
19 |
.jr-container .jr-description.hide-media-library, .jr-container .jr-description.hide-instagram { display: none }
|
20 |
|
21 |
+
.jr-container .switch { position: relative; display: inline-block; margin-left: 5px; width: 45px; height: 24px; }
|
22 |
+
.jr-container .switch input {display:none;}
|
23 |
+
.jr-container .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; -webkit-transition: .4s; transition: .4s; }
|
24 |
+
.jr-container .slider:before { position: absolute; content: ""; height: 22px; width: 22px; left: 0px; bottom: 0px; border: 1px solid #e5e5e5; background-color: white; -webkit-transition: .4s; transition: .4s; }
|
25 |
+
.jr-container input:checked + .slider { background-color: #0085ba; }
|
26 |
+
.jr-container input:focus + .slider { box-shadow: 0 0 1px #0085ba; }
|
27 |
+
.jr-container input:checked + .slider:before { -webkit-transform: translateX(22px); -ms-transform: translateX(22px); transform: translateX(22px); }
|
28 |
+
.jr-container .slider.round { border-radius: 34px; }
|
29 |
+
.jr-container .slider.round:before { border-radius: 50%; }
|
assets/js/jr-insta-admin.js
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
}
|
13 |
});
|
14 |
|
15 |
-
//
|
16 |
$('body').on('change', '.jr-container select[id$="template"]', function(e){
|
17 |
var template = $(this);
|
18 |
if ( template.val() == 'thumbs' || template.val() == 'thumbs-no-border' ) {
|
@@ -28,7 +28,6 @@
|
|
28 |
$('body').on('change', '.jr-container input:radio[id$="search_for"]', function(e){
|
29 |
var search_for = $(this);
|
30 |
if ( search_for.val() != 'username' ) {
|
31 |
-
search_for.closest('.jr-container').find('input[id$="source"]').closest('p').animate({opacity: 'hide' , height: 'hide'}, 200);
|
32 |
search_for.closest('.jr-container').find('[id$="attachment"]:checkbox').closest('p').animate({opacity: 'hide' , height: 'hide'}, 200);
|
33 |
search_for.closest('.jr-container').find('select[id$="images_link"] option[value="local_image_url"]').animate({opacity: 'hide' , height: 'hide'}, 200);
|
34 |
search_for.closest('.jr-container').find('select[id$="images_link"] option[value="user_url"]').animate({opacity: 'hide' , height: 'hide'}, 200);
|
@@ -38,10 +37,7 @@
|
|
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('
|
42 |
-
if ( search_for.closest('.jr-container').find('input:radio[id$="source"]:checked').val() == 'instagram' ) {
|
43 |
-
search_for.closest('.jr-container').find('[id$="attachment"]:checkbox').closest('p').animate({opacity: 'show' , height: 'show'}, 200);
|
44 |
-
}
|
45 |
search_for.closest('.jr-container').find('select[id$="images_link"] option[value="local_image_url"]').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);
|
@@ -51,30 +47,6 @@
|
|
51 |
|
52 |
}
|
53 |
});
|
54 |
-
|
55 |
-
// Hide Refresh hour if source is wp media library
|
56 |
-
$('body').on('change', '.jr-container input:radio[id$="source"]', function(e){
|
57 |
-
var source = $(this);
|
58 |
-
if ( source.val() != 'instagram' ) {
|
59 |
-
source.closest('.jr-container').find('input[id$="refresh_hour"]').closest('p').animate({opacity: 'hide' , height: 'hide'}, 200);
|
60 |
-
source.closest('.jr-container').find('select[id$="image_size"]').closest('p').animate({opacity: 'show' , height: 'show'}, 200);
|
61 |
-
source.closest('.jr-container').find('.jr-media-library-option').animate({opacity: 'show' , height: 'show'}, 200);
|
62 |
-
source.closest('.jr-container').find('.jr-instagram-option').animate({opacity: 'hide' , height: 'hide'}, 200);
|
63 |
-
source.closest('.jr-container').find('.blocked-wrap').animate({opacity: 'hide' , height: 'hide'}, 200);
|
64 |
-
source.closest('.jr-container').find('input[id$="attachment"]').closest('p').animate({opacity: 'hide' , height: 'hide'}, 200);
|
65 |
-
source.closest('.jr-container').find('select[id$="images_link"] option[value="local_image_url"]').animate({opacity: 'show' , height: 'show'}, 200);
|
66 |
-
source.closest('.jr-container').find('select[id$="images_link"] option[value="user_url"]').animate({opacity: 'show' , height: 'show'}, 200);
|
67 |
-
source.closest('.jr-container').find('select[id$="images_link"] option[value="attachment"]').animate({opacity: 'show' , height: 'show'}, 200);
|
68 |
-
source.closest('.jr-container').find('select[id$="images_link"]').val('image_url');
|
69 |
-
} else {
|
70 |
-
source.closest('.jr-container').find('input[id$="refresh_hour"]').closest('p').animate({opacity: 'show' , height: 'show'}, 200);
|
71 |
-
source.closest('.jr-container').find('input[id$="attachment"]').closest('p').animate({opacity: 'show' , height: 'show'}, 200);
|
72 |
-
source.closest('.jr-container').find('.jr-media-library-option').animate({opacity: 'hide' , height: 'hide'}, 200);
|
73 |
-
source.closest('.jr-container').find('.jr-instagram-option').animate({opacity: 'show' , height: 'show'}, 200);
|
74 |
-
source.closest('.jr-container').find('.blocked-wrap').animate({opacity: 'show' , height: 'show'}, 200);
|
75 |
-
$('.jr-container input:checkbox[id$="attachment"]').trigger('change');
|
76 |
-
}
|
77 |
-
});
|
78 |
|
79 |
// Hide blocked images if not checked attachments
|
80 |
$('body').on('change', '.jr-container [id$="attachment"]:checkbox', function(e){
|
@@ -104,45 +76,33 @@
|
|
104 |
}
|
105 |
advanced_container.toggle();
|
106 |
});
|
107 |
-
|
108 |
-
// Toggle blocked images
|
109 |
-
$('body').on('click', '.blocked-images-toggle', function(e){
|
110 |
-
e.preventDefault();
|
111 |
-
var blocked_container = $(this).next();
|
112 |
-
|
113 |
-
if ( blocked_container.is(':hidden') ) {
|
114 |
-
$(this).html('[ - Close ]');
|
115 |
-
} else {
|
116 |
-
$(this).html('[ + Open ]');
|
117 |
-
}
|
118 |
-
blocked_container.toggle();
|
119 |
-
});
|
120 |
|
121 |
// Remove blocked images with ajax
|
122 |
-
$('body').on('click', '.jr-container .
|
123 |
-
|
124 |
-
|
125 |
-
username =
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
$.ajax({
|
130 |
type: 'POST',
|
131 |
url: ajaxurl,
|
132 |
data: {
|
133 |
-
action: '
|
134 |
username : username,
|
135 |
-
id : id,
|
136 |
_ajax_nonce: ajaxNonce
|
137 |
},
|
|
|
|
|
|
|
|
|
138 |
success: function(data, textStatus, XMLHttpRequest) {
|
139 |
-
|
140 |
-
li.fadeOut( "slow", function() {
|
141 |
-
$(this).remove();
|
142 |
-
counter.html(parseInt(counter.html(), 10) - 1);
|
143 |
-
});
|
144 |
-
}
|
145 |
},
|
|
|
|
|
|
|
|
|
146 |
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
147 |
//console.log(XMLHttpRequest.responseText);
|
148 |
}
|
12 |
}
|
13 |
});
|
14 |
|
15 |
+
// Modify options based on template selections
|
16 |
$('body').on('change', '.jr-container select[id$="template"]', function(e){
|
17 |
var template = $(this);
|
18 |
if ( template.val() == 'thumbs' || template.val() == 'thumbs-no-border' ) {
|
28 |
$('body').on('change', '.jr-container input:radio[id$="search_for"]', function(e){
|
29 |
var search_for = $(this);
|
30 |
if ( search_for.val() != 'username' ) {
|
|
|
31 |
search_for.closest('.jr-container').find('[id$="attachment"]:checkbox').closest('p').animate({opacity: 'hide' , height: 'hide'}, 200);
|
32 |
search_for.closest('.jr-container').find('select[id$="images_link"] option[value="local_image_url"]').animate({opacity: 'hide' , height: 'hide'}, 200);
|
33 |
search_for.closest('.jr-container').find('select[id$="images_link"] option[value="user_url"]').animate({opacity: 'hide' , height: 'hide'}, 200);
|
37 |
search_for.closest('.jr-container').find('input[id$="blocked_users"]').closest('p').animate({opacity: 'show' , height: 'show'}, 200);
|
38 |
|
39 |
} else {
|
40 |
+
search_for.closest('.jr-container').find('[id$="attachment"]:checkbox').closest('p').animate({opacity: 'show' , height: 'show'}, 200);
|
|
|
|
|
|
|
41 |
search_for.closest('.jr-container').find('select[id$="images_link"] option[value="local_image_url"]').animate({opacity: 'show' , height: 'show'}, 200);
|
42 |
search_for.closest('.jr-container').find('select[id$="images_link"] option[value="user_url"]').animate({opacity: 'show' , height: 'show'}, 200);
|
43 |
search_for.closest('.jr-container').find('select[id$="images_link"] option[value="attachment"]').animate({opacity: 'show' , height: 'show'}, 200);
|
47 |
|
48 |
}
|
49 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
// Hide blocked images if not checked attachments
|
52 |
$('body').on('change', '.jr-container [id$="attachment"]:checkbox', function(e){
|
76 |
}
|
77 |
advanced_container.toggle();
|
78 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
// Remove blocked images with ajax
|
81 |
+
$('body').on('click', '.jr-container .jr-delete-instagram-dupes', function(e){
|
82 |
+
e.preventDefault();
|
83 |
+
var $this = $(this),
|
84 |
+
username = $(this).data("username"),
|
85 |
+
ajaxNonce = $(this).closest('.jr-container').find('input[name=delete_insta_dupes_nonce]').val();
|
86 |
+
|
|
|
87 |
$.ajax({
|
88 |
type: 'POST',
|
89 |
url: ajaxurl,
|
90 |
data: {
|
91 |
+
action: 'jr_delete_insta_dupes',
|
92 |
username : username,
|
|
|
93 |
_ajax_nonce: ajaxNonce
|
94 |
},
|
95 |
+
beforeSend: function () {
|
96 |
+
$this.prop('disabled', true);
|
97 |
+
$this.closest('.jr-container').find('.jr-spinner').addClass( 'spinner' ).css({'visibility':'visible','float':'none'});
|
98 |
+
},
|
99 |
success: function(data, textStatus, XMLHttpRequest) {
|
100 |
+
$this.closest('.jr-container').find('.deleted-dupes-info').text( 'Removed Duplicates: '+ data.deleted);
|
|
|
|
|
|
|
|
|
|
|
101 |
},
|
102 |
+
complete: function () {
|
103 |
+
$this.prop('disabled', false);
|
104 |
+
$this.closest('.jr-container').find('.jr-spinner').addClass( 'spinner' ).css({'visibility':'hidden','float':'none'});
|
105 |
+
},
|
106 |
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
107 |
//console.log(XMLHttpRequest.responseText);
|
108 |
}
|
instaram_slider.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: Instagram Slider Widget
|
4 |
Plugin URI: http://instagram.jrwebstudio.com/
|
5 |
-
Version: 1.
|
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/
|
@@ -14,17 +14,27 @@ License: GPLv2 or later
|
|
14 |
*/
|
15 |
add_action( 'widgets_init', array( 'JR_InstagramSlider', 'register_widget' ) );
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
/**
|
18 |
* JR_InstagramSlider Class
|
19 |
*/
|
20 |
class JR_InstagramSlider extends WP_Widget {
|
21 |
-
|
22 |
/**
|
23 |
* Plugin version, used for cache-busting of style and script file references.
|
24 |
*
|
25 |
* @var string
|
26 |
*/
|
27 |
-
const VERSION = '1.
|
28 |
|
29 |
/**
|
30 |
* Initialize the plugin by registering widget and loading public scripts
|
@@ -34,8 +44,8 @@ class JR_InstagramSlider extends WP_Widget {
|
|
34 |
|
35 |
// Widget ID and Class Setup
|
36 |
parent::__construct( 'jr_insta_slider', __( 'Instagram Slider', 'jrinstaslider' ), array(
|
37 |
-
|
38 |
-
|
39 |
)
|
40 |
);
|
41 |
|
@@ -53,15 +63,15 @@ class JR_InstagramSlider extends WP_Widget {
|
|
53 |
|
54 |
// Enqueue Plugin Styles and scripts for admin pages
|
55 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue' ) );
|
56 |
-
|
57 |
-
// Action when attachments are deleted
|
58 |
-
add_action( 'delete_attachment', array( $this, 'delete_wp_attachment' ) );
|
59 |
-
|
60 |
// Ajax action to unblock images from widget
|
61 |
-
add_action( '
|
62 |
|
63 |
// Add new attachment field desctiptions
|
64 |
add_filter( 'attachment_fields_to_edit', array( $this, 'insta_attachment_fields' ) , 10, 2 );
|
|
|
|
|
|
|
65 |
}
|
66 |
|
67 |
/**
|
@@ -70,11 +80,11 @@ class JR_InstagramSlider extends WP_Widget {
|
|
70 |
public static function register_widget() {
|
71 |
register_widget( __CLASS__ );
|
72 |
register_sidebar( array(
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
}
|
79 |
|
80 |
/**
|
@@ -101,7 +111,6 @@ class JR_InstagramSlider extends WP_Widget {
|
|
101 |
wp_enqueue_style( 'jr-insta-admin-styles', plugins_url( 'assets/css/jr-insta-admin.css', __FILE__ ), array(), self::VERSION );
|
102 |
|
103 |
wp_enqueue_script( 'jr-insta-admin-script', plugins_url( 'assets/js/jr-insta-admin.js', __FILE__ ), array( 'jquery' ), self::VERSION, true );
|
104 |
-
|
105 |
}
|
106 |
|
107 |
/**
|
@@ -110,9 +119,9 @@ class JR_InstagramSlider extends WP_Widget {
|
|
110 |
* @return mixed
|
111 |
*/
|
112 |
public function widget( $args, $instance ) {
|
113 |
-
|
114 |
extract( $args );
|
115 |
-
|
116 |
//Our variables from the widget settings.
|
117 |
$title = apply_filters( 'widget_title', $instance['title'] );
|
118 |
|
@@ -122,12 +131,12 @@ class JR_InstagramSlider extends WP_Widget {
|
|
122 |
if ( $title ) {
|
123 |
echo $before_title . $title . $after_title;
|
124 |
}
|
125 |
-
|
126 |
do_action( 'jr_instagram', $instance );
|
127 |
-
|
128 |
echo $after_widget;
|
129 |
}
|
130 |
-
|
131 |
/**
|
132 |
* Update the widget settings
|
133 |
*
|
@@ -137,13 +146,12 @@ class JR_InstagramSlider extends WP_Widget {
|
|
137 |
* @return array
|
138 |
*/
|
139 |
public function update( $new_instance, $instance ) {
|
140 |
-
|
141 |
$instance['title'] = strip_tags( $new_instance['title'] );
|
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'];
|
149 |
$instance['images_link'] = $new_instance['images_link'];
|
@@ -161,6 +169,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
161 |
$instance['caption_words'] = $new_instance['caption_words'];
|
162 |
$instance['slidespeed'] = $new_instance['slidespeed'];
|
163 |
$instance['description'] = $new_instance['description'];
|
|
|
164 |
|
165 |
return $instance;
|
166 |
}
|
@@ -179,7 +188,6 @@ class JR_InstagramSlider extends WP_Widget {
|
|
179 |
'username' => '',
|
180 |
'hashtag' => '',
|
181 |
'blocked_users' => '',
|
182 |
-
'source' => 'instagram',
|
183 |
'attachment' => 0,
|
184 |
'template' => 'slider',
|
185 |
'images_link' => 'image_url',
|
@@ -196,11 +204,12 @@ class JR_InstagramSlider extends WP_Widget {
|
|
196 |
'animation' => 'slide',
|
197 |
'caption_words' => 100,
|
198 |
'slidespeed' => 7000,
|
199 |
-
'description' => array( 'username', 'time','caption' )
|
200 |
-
|
|
|
201 |
|
202 |
$instance = wp_parse_args( (array) $instance, $defaults );
|
203 |
-
|
204 |
?>
|
205 |
<div class="jr-container">
|
206 |
<p>
|
@@ -212,93 +221,34 @@ class JR_InstagramSlider extends WP_Widget {
|
|
212 |
<span class="jr-search-for-container"><label class="jr-seach-for"><input type="radio" id="<?php echo $this->get_field_id( 'search_for' ); ?>" name="<?php echo $this->get_field_name( 'search_for' ); ?>" value="username" <?php checked( 'username', $instance['search_for'] ); ?> /> <?php _e( 'Username:', 'jrinstaslider' ); ?></label> <input id="<?php echo $this->get_field_id( 'username' ); ?>" class="inline-field-text" name="<?php echo $this->get_field_name( 'username' ); ?>" value="<?php echo $instance['username']; ?>" /></span>
|
213 |
<span class="jr-search-for-container"><label class="jr-seach-for"><input type="radio" id="<?php echo $this->get_field_id( 'search_for' ); ?>" name="<?php echo $this->get_field_name( 'search_for' ); ?>" value="hashtag" <?php checked( 'hashtag', $instance['search_for'] ); ?> /> <?php _e( 'Hashtag:', 'jrinstaslider' ); ?></label> <input id="<?php echo $this->get_field_id( 'hashtag' ); ?>" class="inline-field-text" name="<?php echo $this->get_field_name( 'hashtag' ); ?>" value="<?php echo $instance['hashtag']; ?>" /> <small><?php _e('without # sign', 'jrinstaslider'); ?></small></span>
|
214 |
</p>
|
215 |
-
<p class="<?php if ( '
|
216 |
-
<
|
217 |
-
<label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'source' ); ?>" name="<?php echo $this->get_field_name( 'source' ); ?>" value="instagram" <?php checked( 'instagram', $instance['source'] ); ?> /> <?php _e( 'Instagram', 'jrinstaslider' ); ?></label>
|
218 |
-
<label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'source' ); ?>" name="<?php echo $this->get_field_name( 'source' ); ?>" value="media_library" <?php checked( 'media_library', $instance['source'] ); ?> /> <?php _e( 'WP Media Library', 'jrinstaslider' ); ?></label>
|
219 |
-
<?php
|
220 |
-
|
221 |
-
$saved_images = 0;
|
222 |
-
$username = '';
|
223 |
-
|
224 |
-
if ( 'instagram' == $instance['source'] ) {
|
225 |
-
$media_option_class = 'hide-media-library';
|
226 |
-
$insta_option_class = '';
|
227 |
-
|
228 |
-
} else {
|
229 |
-
$media_option_class = '';
|
230 |
-
$insta_option_class = 'hide-instagram';
|
231 |
-
}
|
232 |
-
|
233 |
-
if ( isset( $instance['username'] ) && ( !empty( $instance['username'] ) ) ) {
|
234 |
-
$username = $instance['username'];
|
235 |
-
$savedinsta_args = array(
|
236 |
-
'post_type' => 'attachment',
|
237 |
-
'post_status' => 'inherit',
|
238 |
-
'post_mime_type' => 'image',
|
239 |
-
'posts_per_page' => -1,
|
240 |
-
'orderby' => 'rand',
|
241 |
-
'no_found_rows' => true,
|
242 |
-
'meta_query' => array(
|
243 |
-
array(
|
244 |
-
'key' => 'jr_insta_username',
|
245 |
-
'value' => $instance['username'],
|
246 |
-
'compare' => '='
|
247 |
-
),
|
248 |
-
),
|
249 |
-
);
|
250 |
-
$savedinsta = new WP_Query( $savedinsta_args );
|
251 |
-
$saved_images = $savedinsta->post_count;
|
252 |
-
}
|
253 |
-
|
254 |
-
if ( $saved_images <= 0 ) {
|
255 |
-
echo '<span class="jr-description jr-media-library-option '.$media_option_class.'"><strong>WP Media Library</strong> will not show any images for '. $username .' because there are no saved images yet!</span>';
|
256 |
-
} else {
|
257 |
-
echo '<span class="jr-description jr-media-library-option '.$media_option_class.'"><strong>WP Media Library</strong> can display up to <strong>'. $saved_images .'</strong> images that are saved in media library for <strong>'. $username.'</strong>!<br> This option will NOT check for new images on Instagram!</span>';
|
258 |
-
}
|
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 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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']; ?>" />
|
275 |
</label>
|
276 |
</p>
|
277 |
-
<p
|
278 |
<label for="<?php echo $this->get_field_id( 'refresh_hour' ); ?>"><strong><?php _e( 'Check for new images every:', 'jrinstaslider' ); ?></strong>
|
279 |
<input class="small-text" id="<?php echo $this->get_field_id( 'refresh_hour' ); ?>" name="<?php echo $this->get_field_name( 'refresh_hour' ); ?>" value="<?php echo $instance['refresh_hour']; ?>" />
|
280 |
<span><?php _e('hours', 'jrinstaslider'); ?></span>
|
281 |
</label>
|
282 |
-
</p>
|
283 |
-
<?php
|
284 |
-
$user_opt = get_option( 'jr_insta_'. md5( $instance['username'] ) );
|
285 |
-
if ( isset( $user_opt['deleted_images'] ) && ( !empty( $user_opt['deleted_images'] ) && ( $instance['source'] == 'instagram' ) && ( $instance['attachment'] ) && ( 'username' == $instance['search_for'] ) ) ) {
|
286 |
-
$deleted_count = count( $user_opt['deleted_images'] );
|
287 |
-
echo '<div class="blocked-wrap">';
|
288 |
-
wp_nonce_field( 'jr_unblock_instagram_image', 'unblock_images_nonce' );
|
289 |
-
echo "<strong>{$instance['username']}</strong> has <strong class='blocked-count-nr'>{$deleted_count}</strong> blocked images! ";
|
290 |
-
echo "<a href='#' class='blocked-images-toggle'>[ + Open ]</a>";
|
291 |
-
echo '<div class="blocked-images hidden">';
|
292 |
-
echo '<ul>';
|
293 |
-
foreach ( $user_opt['deleted_images'] as $id => $image ) {
|
294 |
-
echo "<li class='blocked-column' data-id='{$id}'><span class='blocked-imgcontainer'><span class='jr-allow-yes dashicons dashicons-yes'></span><img src='{$image}'></span></li>";
|
295 |
-
}
|
296 |
-
echo '</ul>';
|
297 |
-
echo '</div>';
|
298 |
-
echo "<span class='jr-description'>You can unblock instagram images by clicking the ones you want to have on the media library.</span>";
|
299 |
-
echo '</div>';
|
300 |
-
}
|
301 |
-
?>
|
302 |
<p>
|
303 |
<label for="<?php echo $this->get_field_id( 'template' ); ?>"><strong><?php _e( 'Template', 'jrinstaslider' ); ?></strong>
|
304 |
<select class="widefat" name="<?php echo $this->get_field_name( 'template' ); ?>" id="<?php echo $this->get_field_id( 'template' ); ?>">
|
@@ -339,8 +289,8 @@ class JR_InstagramSlider extends WP_Widget {
|
|
339 |
<select class="widefat" name="<?php echo $this->get_field_name( 'images_link' ); ?>" id="<?php echo $this->get_field_id( 'images_link' ); ?>">
|
340 |
<option value="image_url" <?php selected( $instance['images_link'], 'image_url', true); ?>><?php _e( 'Instagram Image', 'jrinstaslider' ); ?></option>
|
341 |
<option class="<?php if ( 'hashtag' == $instance['search_for'] ) echo 'hidden'; ?>" value="user_url" <?php selected( $instance['images_link'], 'user_url', true); ?>><?php _e( 'Instagram Profile', 'jrinstaslider' ); ?></option>
|
342 |
-
<option class="<?php if ( ( !$instance['attachment']
|
343 |
-
<option class="<?php if ( ( !$instance['attachment']
|
344 |
<option value="custom_url" <?php selected( $instance['images_link'], 'custom_url', true ); ?>><?php _e( 'Custom Link', 'jrinstaslider' ); ?></option>
|
345 |
<option value="none" <?php selected( $instance['images_link'], 'none', true); ?>><?php _e( 'None', 'jrinstaslider' ); ?></option>
|
346 |
</select>
|
@@ -375,60 +325,68 @@ class JR_InstagramSlider extends WP_Widget {
|
|
375 |
<label for="<?php echo $this->get_field_id( 'image_link_class' ); ?>"><?php _e( 'Image Link class', 'jrinstaslider' ); ?>:</label>
|
376 |
<input class="widefat" id="<?php echo $this->get_field_id( 'image_link_class' ); ?>" name="<?php echo $this->get_field_name( 'image_link_class' ); ?>" value="<?php echo $instance['image_link_class']; ?>" />
|
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>
|
388 |
-
<p>
|
389 |
-
<?php _e( 'Slider Navigation Controls:', 'jrinstaslider' ); ?><br>
|
390 |
-
<label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'controls' ); ?>" name="<?php echo $this->get_field_name( 'controls' ); ?>" value="prev_next" <?php checked( 'prev_next', $instance['controls'] ); ?> /> <?php _e( 'Prev & Next', 'jrinstaslider' ); ?></label>
|
391 |
-
<label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'controls' ); ?>" name="<?php echo $this->get_field_name( 'controls' ); ?>" value="numberless" <?php checked( 'numberless', $instance['controls'] ); ?> /> <?php _e( 'Dotted', 'jrinstaslider' ); ?></label>
|
392 |
-
<label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'controls' ); ?>" name="<?php echo $this->get_field_name( 'controls' ); ?>" value="none" <?php checked( 'none', $instance['controls'] ); ?> /> <?php _e( 'No Navigation', 'jrinstaslider' ); ?></label>
|
393 |
-
</p>
|
394 |
-
<p>
|
395 |
-
<?php _e( 'Slider Animation:', 'jrinstaslider' ); ?><br>
|
396 |
-
<label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'animation' ); ?>" name="<?php echo $this->get_field_name( 'animation' ); ?>" value="slide" <?php checked( 'slide', $instance['animation'] ); ?> /> <?php _e( 'Slide', 'jrinstaslider' ); ?></label>
|
397 |
-
<label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'animation' ); ?>" name="<?php echo $this->get_field_name( 'animation' ); ?>" value="fade" <?php checked( 'fade', $instance['animation'] ); ?> /> <?php _e( 'Fade', 'jrinstaslider' ); ?></label>
|
398 |
</p>
|
399 |
-
<p>
|
400 |
-
<label
|
401 |
-
<input class="
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
<
|
414 |
-
|
415 |
-
<
|
416 |
-
<
|
417 |
-
</
|
418 |
-
<
|
419 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
</div>
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
432 |
}
|
433 |
|
434 |
/**
|
@@ -446,6 +404,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
446 |
}
|
447 |
}
|
448 |
|
|
|
449 |
/**
|
450 |
* Add shorcode function
|
451 |
* @param array $atts shortcode attributes
|
@@ -461,6 +420,21 @@ class JR_InstagramSlider extends WP_Widget {
|
|
461 |
}
|
462 |
}
|
463 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
464 |
/**
|
465 |
* Echoes the Display Instagram Images method
|
466 |
*
|
@@ -472,6 +446,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
472 |
echo $this->display_images( $args );
|
473 |
}
|
474 |
|
|
|
475 |
/**
|
476 |
* Runs the query for images and returns the html
|
477 |
*
|
@@ -484,7 +459,6 @@ class JR_InstagramSlider extends WP_Widget {
|
|
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;
|
489 |
$template = isset( $args['template'] ) ? $args['template'] : 'slider';
|
490 |
$orderby = isset( $args['orderby'] ) ? $args['orderby'] : 'rand';
|
@@ -503,6 +477,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
503 |
$slidespeed = isset( $args['slidespeed'] ) ? $args['slidespeed'] : 7000;
|
504 |
$description = isset( $args['description'] ) ? $args['description'] : array();
|
505 |
$widget_id = isset( $args['widget_id'] ) ? $args['widget_id'] : preg_replace( '/[^0-9]/', '', $this->id );
|
|
|
506 |
|
507 |
if ( !empty( $description ) && !is_array( $description ) ) {
|
508 |
$description = explode( ',', $description );
|
@@ -517,20 +492,19 @@ class JR_InstagramSlider extends WP_Widget {
|
|
517 |
$search_for['username'] = $username;
|
518 |
}
|
519 |
|
520 |
-
if ( $
|
521 |
$refresh_hour = 5;
|
522 |
}
|
523 |
|
524 |
$template_args = array(
|
525 |
'search_for' => $search,
|
526 |
-
'source' => $source,
|
527 |
'attachment' => $attachment,
|
528 |
-
|
529 |
'link_rel' => $image_link_rel,
|
530 |
'link_class' => $image_link_class,
|
531 |
'no_pin' => $no_pin,
|
532 |
'caption_words' => $caption_words
|
533 |
-
|
534 |
|
535 |
$images_div_class = 'jr-insta-thumb';
|
536 |
$ul_class = ( $template == 'thumbs-no-border' ) ? 'thumbnails no-border jr_col_' . $columns : 'thumbnails jr_col_' . $columns;
|
@@ -560,7 +534,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
560 |
"</script>" . "\n";
|
561 |
} else {
|
562 |
$images_div_class = 'pllexislider pllexislider-overlay instaslider-nr-'. $widget_id;
|
563 |
-
|
564 |
"<script type='text/javascript'>" . "\n" .
|
565 |
" jQuery(document).ready(function($) {" . "\n" .
|
566 |
" $('.instaslider-nr-{$widget_id}').pllexislider({" . "\n" .
|
@@ -584,23 +558,33 @@ class JR_InstagramSlider extends WP_Widget {
|
|
584 |
" });" . "\n" .
|
585 |
"</script>" . "\n";
|
586 |
}
|
587 |
-
|
588 |
|
589 |
$images_div = "<div class='{$images_div_class}'>\n";
|
590 |
$images_ul = "<ul class='no-bullet {$ul_class}'>\n";
|
591 |
|
592 |
$output = __( 'No images found! <br> Try some other hashtag or username', 'jrinstaslider' );
|
593 |
|
594 |
-
if ( ( $search == 'user' && $attachment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
595 |
|
596 |
$query_args = array(
|
597 |
'post_type' => 'attachment',
|
598 |
'post_status' => 'inherit',
|
599 |
'post_mime_type' => 'image',
|
600 |
-
'posts_per_page' =>
|
601 |
-
'orderby' => 'rand',
|
602 |
'no_found_rows' => true
|
603 |
-
|
604 |
|
605 |
if ( $orderby != 'rand' ) {
|
606 |
|
@@ -611,59 +595,98 @@ class JR_InstagramSlider extends WP_Widget {
|
|
611 |
$query_args['orderby'] = 'meta_value_num';
|
612 |
$query_args['order'] = $orderby[1];
|
613 |
}
|
614 |
-
|
615 |
-
if ( $
|
616 |
-
|
|
|
|
|
|
|
|
|
617 |
$query_args['meta_query'] = array(
|
618 |
array(
|
619 |
'key' => 'jr_insta_username',
|
620 |
'value' => $username,
|
621 |
'compare' => '='
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
} else {
|
626 |
-
|
627 |
-
$attachment_ids = $this->instagram_data( $search_for, $refresh_hour, $images_number, true );
|
628 |
-
|
629 |
-
if ( is_array( $attachment_ids ) && !empty( $attachment_ids ) ) {
|
630 |
-
$query_args['post__in'] = $attachment_ids;
|
631 |
-
} else {
|
632 |
-
if ( is_array( $attachment_ids ) ) {
|
633 |
-
return __( 'No images found! <br> Try some other hashtag or username!', 'jrinstaslider' );
|
634 |
-
} else {
|
635 |
-
return $attachment_ids;
|
636 |
-
}
|
637 |
-
}
|
638 |
}
|
639 |
-
|
640 |
$instagram_images = new WP_Query( $query_args );
|
641 |
|
642 |
-
if ( $instagram_images->have_posts() ) {
|
643 |
-
|
644 |
$output = $slider_script . $images_div . $images_ul;
|
645 |
-
|
646 |
while ( $instagram_images->have_posts() ) : $instagram_images->the_post();
|
647 |
-
|
648 |
-
$id = get_the_id();
|
649 |
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
|
|
|
|
661 |
|
662 |
-
|
663 |
|
664 |
endwhile;
|
665 |
|
666 |
-
$output .= "</ul>\n</div>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
667 |
}
|
668 |
|
669 |
wp_reset_postdata();
|
@@ -713,7 +736,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
713 |
$output .= $this->get_template( $template, $template_args );
|
714 |
}
|
715 |
|
716 |
-
$output .= "</ul>\n</div>";
|
717 |
}
|
718 |
}
|
719 |
|
@@ -734,7 +757,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
734 |
|
735 |
$link_to = isset( $args['link_to'] ) ? $args['link_to'] : false;
|
736 |
|
737 |
-
if ( ( $args['search_for'] == 'user' && $args['attachment'] !== true
|
738 |
$caption = $args['caption'];
|
739 |
$time = $args['timestamp'];
|
740 |
$username = $args['username'];
|
@@ -776,66 +799,66 @@ class JR_InstagramSlider extends WP_Widget {
|
|
776 |
|
777 |
$output .= "<li>";
|
778 |
|
779 |
-
|
780 |
|
781 |
-
|
782 |
-
|
783 |
-
$output .= "<div class='jr-insta-datacontainer'>\n";
|
784 |
-
|
785 |
-
if ( $time && in_array( 'time', $args['description'] ) ) {
|
786 |
-
$time = human_time_diff( $time );
|
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 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
|
|
|
|
|
|
|
|
798 |
|
799 |
-
|
|
|
|
|
|
|
800 |
}
|
801 |
|
|
|
|
|
|
|
802 |
$output .= "</li>";
|
803 |
-
|
804 |
// Template : Slider with text Overlay on mouse over
|
805 |
} elseif ( $template == 'slider-overlay' ) {
|
806 |
|
807 |
$output .= "<li>";
|
808 |
|
809 |
-
|
810 |
|
811 |
-
|
812 |
-
|
813 |
-
$output .= "<div class='jr-insta-wrap'>\n";
|
814 |
|
815 |
-
|
816 |
|
817 |
-
|
818 |
-
$time = human_time_diff( $time );
|
819 |
-
$output .= "<span class='jr-insta-time'>{$time} ago</span>\n";
|
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 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
}
|
831 |
|
832 |
-
|
|
|
|
|
833 |
|
834 |
-
|
|
|
|
|
|
|
835 |
}
|
|
|
|
|
|
|
|
|
|
|
836 |
|
837 |
$output .= "</li>";
|
838 |
-
|
839 |
// Template : Thumbnails no text
|
840 |
} elseif ( $template == 'thumbs' || $template == 'thumbs-no-border' ) {
|
841 |
|
@@ -851,6 +874,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
851 |
return $output;
|
852 |
}
|
853 |
|
|
|
854 |
/**
|
855 |
* Trigger refresh for new data
|
856 |
* @param bolean $instaData
|
@@ -862,9 +886,22 @@ class JR_InstagramSlider extends WP_Widget {
|
|
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;
|
@@ -877,6 +914,32 @@ class JR_InstagramSlider extends WP_Widget {
|
|
877 |
return false;
|
878 |
}
|
879 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
880 |
/**
|
881 |
* Stores the fetched data from instagram in WordPress DB using transients
|
882 |
*
|
@@ -910,7 +973,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
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 |
|
@@ -1004,9 +1067,9 @@ class JR_InstagramSlider extends WP_Widget {
|
|
1004 |
if ( ( $search == 'hashtag' ) || ( $search == 'user' && !$attachment ) ) {
|
1005 |
|
1006 |
$instaData[] = $image_data;
|
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']] ) ) ) {
|
@@ -1014,11 +1077,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
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 {
|
1024 |
|
@@ -1029,7 +1088,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
1029 |
$old_opts['saved_images'][$image_data['id']] = $id;
|
1030 |
|
1031 |
$instaData[$image_data['id']] = $id;
|
1032 |
-
|
1033 |
} else {
|
1034 |
|
1035 |
return $id;
|
@@ -1061,6 +1120,67 @@ class JR_InstagramSlider extends WP_Widget {
|
|
1061 |
return $instaData;
|
1062 |
}
|
1063 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1064 |
|
1065 |
/**
|
1066 |
* Get Instagram Ids from Usernames into array
|
@@ -1082,12 +1202,12 @@ class JR_InstagramSlider extends WP_Widget {
|
|
1082 |
}
|
1083 |
|
1084 |
$response = wp_remote_get( 'https://www.instagram.com/' . trim( $user ), array( 'sslverify' => false, 'timeout' => 60 ) );
|
1085 |
-
|
1086 |
if ( is_wp_error( $response ) ) {
|
1087 |
|
1088 |
return $response->get_error_message();
|
1089 |
}
|
1090 |
-
|
1091 |
if ( $response['response']['code'] == 200 ) {
|
1092 |
|
1093 |
$json = str_replace( 'window._sharedData = ', '', strstr( $response['body'], 'window._sharedData = ' ) );
|
@@ -1114,11 +1234,11 @@ class JR_InstagramSlider extends WP_Widget {
|
|
1114 |
if ( $results && is_array( $results ) ) {
|
1115 |
|
1116 |
$user_id = isset( $results['entry_data']['ProfilePage'][0]['user']['id'] ) ? $results['entry_data']['ProfilePage'][0]['user']['id'] : false;
|
1117 |
-
|
1118 |
if ( $user_id ) {
|
1119 |
|
1120 |
$user_ids[$user] = $user_id;
|
1121 |
-
|
1122 |
set_transient( 'jr_insta_user_ids', $user_ids );
|
1123 |
}
|
1124 |
}
|
@@ -1158,9 +1278,6 @@ class JR_InstagramSlider extends WP_Widget {
|
|
1158 |
*/
|
1159 |
private function save_wp_attachment( $image_data ) {
|
1160 |
|
1161 |
-
// Increase Time limit to 3 min
|
1162 |
-
set_time_limit( 180 );
|
1163 |
-
|
1164 |
// Remove Instagram chace key from url
|
1165 |
$clean_url = esc_url( remove_query_arg( 'ig_cache_key', $image_data['url'] ) );
|
1166 |
|
@@ -1194,7 +1311,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
1194 |
|
1195 |
$id = media_handle_sideload( $file_array, 0, NULL, array(
|
1196 |
'post_excerpt' => $image_data['caption']
|
1197 |
-
|
1198 |
|
1199 |
// If error storing permanently, unlink
|
1200 |
if ( is_wp_error( $id ) ) {
|
@@ -1231,7 +1348,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
1231 |
"label" => __( "Instagram Username" ),
|
1232 |
"input" => "html",
|
1233 |
"html" => "<span style='line-height:31px'><a target='_blank' href='https://www.instagram.com/{$instagram_username}/'>{$instagram_username}</a></span>"
|
1234 |
-
|
1235 |
|
1236 |
$instagram_link = get_post_meta( $post->ID, 'jr_insta_link', true );
|
1237 |
if ( !empty( $instagram_link ) ) {
|
@@ -1239,7 +1356,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
1239 |
"label" => __( "Instagram Image" ),
|
1240 |
"input" => "html",
|
1241 |
"html" => "<span style='line-height:31px'><a target='_blank' href='{$instagram_link}'>{$instagram_link}</a></span>"
|
1242 |
-
|
1243 |
}
|
1244 |
|
1245 |
$instagram_date = get_post_meta( $post->ID, 'jr_insta_timestamp', true );
|
@@ -1249,7 +1366,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
1249 |
"label" => __( "Posted on Instagram" ),
|
1250 |
"input" => "html",
|
1251 |
"html" => "<span style='line-height:31px'>{$instagram_date}</span>"
|
1252 |
-
|
1253 |
}
|
1254 |
}
|
1255 |
|
@@ -1285,40 +1402,47 @@ class JR_InstagramSlider extends WP_Widget {
|
|
1285 |
}
|
1286 |
|
1287 |
/**
|
1288 |
-
*
|
1289 |
-
*
|
1290 |
-
* @return void
|
1291 |
*/
|
1292 |
-
public function
|
1293 |
-
|
1294 |
-
$username = get_post_meta( $post_id, 'jr_insta_username', true );
|
1295 |
-
|
1296 |
-
if ( !empty( $username ) ) {
|
1297 |
-
delete_transient( 'jr_insta_' . md5( $username ) );
|
1298 |
-
}
|
1299 |
-
}
|
1300 |
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1310 |
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
|
|
|
|
|
|
|
|
1314 |
|
1315 |
-
|
1316 |
-
unset( $user_options['saved_images'][$post['id']] );
|
1317 |
-
|
1318 |
-
update_option( $option_id, $user_options );
|
1319 |
-
delete_transient( $option_id );
|
1320 |
-
|
1321 |
-
die('success');
|
1322 |
}
|
1323 |
|
1324 |
/**
|
@@ -1331,7 +1455,7 @@ class JR_InstagramSlider extends WP_Widget {
|
|
1331 |
* @return the sanitized input
|
1332 |
*/
|
1333 |
private function sanitize( $input ) {
|
1334 |
-
|
1335 |
if ( !empty( $input ) ) {
|
1336 |
$utf8_2byte = 0xC0 /*1100 0000*/ ;
|
1337 |
$utf8_2byte_bmask = 0xE0 /*1110 0000*/ ;
|
2 |
/*
|
3 |
Plugin Name: Instagram Slider Widget
|
4 |
Plugin URI: http://instagram.jrwebstudio.com/
|
5 |
+
Version: 1.4.0
|
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/
|
14 |
*/
|
15 |
add_action( 'widgets_init', array( 'JR_InstagramSlider', 'register_widget' ) );
|
16 |
|
17 |
+
if ( !ini_get( 'max_execution_time' ) || ini_get( 'max_execution_time' ) < 300 ) {
|
18 |
+
|
19 |
+
ini_set( 'max_execution_time', 300 );
|
20 |
+
|
21 |
+
$disabled = explode( ',', ini_get( 'disable_functions' ) );
|
22 |
+
if ( !in_array( 'set_time_limit', $disabled ) ) {
|
23 |
+
set_time_limit( 300 );
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
/**
|
28 |
* JR_InstagramSlider Class
|
29 |
*/
|
30 |
class JR_InstagramSlider extends WP_Widget {
|
31 |
+
|
32 |
/**
|
33 |
* Plugin version, used for cache-busting of style and script file references.
|
34 |
*
|
35 |
* @var string
|
36 |
*/
|
37 |
+
const VERSION = '1.4.0';
|
38 |
|
39 |
/**
|
40 |
* Initialize the plugin by registering widget and loading public scripts
|
44 |
|
45 |
// Widget ID and Class Setup
|
46 |
parent::__construct( 'jr_insta_slider', __( 'Instagram Slider', 'jrinstaslider' ), array(
|
47 |
+
'classname' => 'jr-insta-slider',
|
48 |
+
'description' => __( 'A widget that displays a slider with instagram images ', 'jrinstaslider' )
|
49 |
)
|
50 |
);
|
51 |
|
63 |
|
64 |
// Enqueue Plugin Styles and scripts for admin pages
|
65 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue' ) );
|
66 |
+
|
|
|
|
|
|
|
67 |
// Ajax action to unblock images from widget
|
68 |
+
add_action( 'wp_ajax_jr_delete_insta_dupes', array( $this, 'delete_dupes' ) );
|
69 |
|
70 |
// Add new attachment field desctiptions
|
71 |
add_filter( 'attachment_fields_to_edit', array( $this, 'insta_attachment_fields' ) , 10, 2 );
|
72 |
+
|
73 |
+
// Add action for single cron events
|
74 |
+
add_action( 'jr_insta_cron', array( $this, 'jr_cron_trigger' ), 10 , 3 );
|
75 |
}
|
76 |
|
77 |
/**
|
80 |
public static function register_widget() {
|
81 |
register_widget( __CLASS__ );
|
82 |
register_sidebar( array(
|
83 |
+
'name' => __( 'Instagram Slider - Shortcode Generator', 'jrinstaslider' ),
|
84 |
+
'id' => 'jr-insta-shortcodes',
|
85 |
+
'description' => __( "1. Drag Instagram Slider widget here. 2. Fill in the fields and hit save. 3. Copy the shortocde generated at the bottom of the widget form and use it on posts or pages.", 'jrinstaslider' )
|
86 |
+
)
|
87 |
+
);
|
88 |
}
|
89 |
|
90 |
/**
|
111 |
wp_enqueue_style( 'jr-insta-admin-styles', plugins_url( 'assets/css/jr-insta-admin.css', __FILE__ ), array(), self::VERSION );
|
112 |
|
113 |
wp_enqueue_script( 'jr-insta-admin-script', plugins_url( 'assets/js/jr-insta-admin.js', __FILE__ ), array( 'jquery' ), self::VERSION, true );
|
|
|
114 |
}
|
115 |
|
116 |
/**
|
119 |
* @return mixed
|
120 |
*/
|
121 |
public function widget( $args, $instance ) {
|
122 |
+
|
123 |
extract( $args );
|
124 |
+
|
125 |
//Our variables from the widget settings.
|
126 |
$title = apply_filters( 'widget_title', $instance['title'] );
|
127 |
|
131 |
if ( $title ) {
|
132 |
echo $before_title . $title . $after_title;
|
133 |
}
|
134 |
+
|
135 |
do_action( 'jr_instagram', $instance );
|
136 |
+
|
137 |
echo $after_widget;
|
138 |
}
|
139 |
+
|
140 |
/**
|
141 |
* Update the widget settings
|
142 |
*
|
146 |
* @return array
|
147 |
*/
|
148 |
public function update( $new_instance, $instance ) {
|
149 |
+
|
150 |
$instance['title'] = strip_tags( $new_instance['title'] );
|
151 |
$instance['search_for'] = $new_instance['search_for'];
|
152 |
$instance['username'] = $new_instance['username'];
|
153 |
$instance['hashtag'] = $new_instance['hashtag'];
|
154 |
$instance['blocked_users'] = $new_instance['blocked_users'];
|
|
|
155 |
$instance['attachment'] = $new_instance['attachment'];
|
156 |
$instance['template'] = $new_instance['template'];
|
157 |
$instance['images_link'] = $new_instance['images_link'];
|
169 |
$instance['caption_words'] = $new_instance['caption_words'];
|
170 |
$instance['slidespeed'] = $new_instance['slidespeed'];
|
171 |
$instance['description'] = $new_instance['description'];
|
172 |
+
$instance['support_author'] = $new_instance['support_author'];
|
173 |
|
174 |
return $instance;
|
175 |
}
|
188 |
'username' => '',
|
189 |
'hashtag' => '',
|
190 |
'blocked_users' => '',
|
|
|
191 |
'attachment' => 0,
|
192 |
'template' => 'slider',
|
193 |
'images_link' => 'image_url',
|
204 |
'animation' => 'slide',
|
205 |
'caption_words' => 100,
|
206 |
'slidespeed' => 7000,
|
207 |
+
'description' => array( 'username', 'time','caption' ),
|
208 |
+
'support_author' => 0
|
209 |
+
);
|
210 |
|
211 |
$instance = wp_parse_args( (array) $instance, $defaults );
|
212 |
+
|
213 |
?>
|
214 |
<div class="jr-container">
|
215 |
<p>
|
221 |
<span class="jr-search-for-container"><label class="jr-seach-for"><input type="radio" id="<?php echo $this->get_field_id( 'search_for' ); ?>" name="<?php echo $this->get_field_name( 'search_for' ); ?>" value="username" <?php checked( 'username', $instance['search_for'] ); ?> /> <?php _e( 'Username:', 'jrinstaslider' ); ?></label> <input id="<?php echo $this->get_field_id( 'username' ); ?>" class="inline-field-text" name="<?php echo $this->get_field_name( 'username' ); ?>" value="<?php echo $instance['username']; ?>" /></span>
|
222 |
<span class="jr-search-for-container"><label class="jr-seach-for"><input type="radio" id="<?php echo $this->get_field_id( 'search_for' ); ?>" name="<?php echo $this->get_field_name( 'search_for' ); ?>" value="hashtag" <?php checked( 'hashtag', $instance['search_for'] ); ?> /> <?php _e( 'Hashtag:', 'jrinstaslider' ); ?></label> <input id="<?php echo $this->get_field_id( 'hashtag' ); ?>" class="inline-field-text" name="<?php echo $this->get_field_name( 'hashtag' ); ?>" value="<?php echo $instance['hashtag']; ?>" /> <small><?php _e('without # sign', 'jrinstaslider'); ?></small></span>
|
223 |
</p>
|
224 |
+
<p class="<?php if ( 'hashtag' != $instance['search_for'] ) echo 'hidden'; ?>">
|
225 |
+
<label for="<?php echo $this->get_field_id( 'blocked_users' ); ?>"><?php _e( 'Block Users', 'jrinstaslider' ); ?>:</label>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
<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']; ?>" />
|
227 |
<span class="jr-description"><?php _e( 'Enter usernames separated by commas whose images you don\'t want to show', 'jrinstaslider' ); ?></span>
|
228 |
+
</p>
|
229 |
+
<p class="<?php if ( 'username' != $instance['search_for'] ) echo 'hidden'; ?>"><strong><?php _e( 'Save and Display Images from Media Library: ', 'jrinstaslider' ); ?></strong>
|
230 |
+
<label class="switch" for="<?php echo $this->get_field_id( 'attachment' ); ?>">
|
231 |
+
<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'] ); ?> /><span class="slider round"></span></label>
|
232 |
+
<br><span class="jr-description"><?php _e( ' Turn on to save Instagram Images into WordPress media library.', 'jrinstaslider') ?></span>
|
233 |
+
<?php
|
234 |
+
if ( isset ( $instance['username'] ) && !empty($instance['username'] ) ) {
|
235 |
+
echo '<br><button class="button action jr-delete-instagram-dupes" type="button" data-username="'.$instance['username'].'"><strong>Remove</strong> duplicate images for <strong>'.$instance['username'].'</strong></button><span class="jr-spinner"></span>';
|
236 |
+
echo '<br><br><strong><span class="deleted-dupes-info"></span></strong>';
|
237 |
+
wp_nonce_field( 'jr_delete_instagram_dupes', 'delete_insta_dupes_nonce' );
|
238 |
+
}
|
239 |
+
?>
|
240 |
+
</p>
|
241 |
<p>
|
242 |
<label for="<?php echo $this->get_field_id( 'images_number' ); ?>"><strong><?php _e( 'Number of images to show:', 'jrinstaslider' ); ?></strong>
|
243 |
<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']; ?>" />
|
244 |
</label>
|
245 |
</p>
|
246 |
+
<p>
|
247 |
<label for="<?php echo $this->get_field_id( 'refresh_hour' ); ?>"><strong><?php _e( 'Check for new images every:', 'jrinstaslider' ); ?></strong>
|
248 |
<input class="small-text" id="<?php echo $this->get_field_id( 'refresh_hour' ); ?>" name="<?php echo $this->get_field_name( 'refresh_hour' ); ?>" value="<?php echo $instance['refresh_hour']; ?>" />
|
249 |
<span><?php _e('hours', 'jrinstaslider'); ?></span>
|
250 |
</label>
|
251 |
+
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
<p>
|
253 |
<label for="<?php echo $this->get_field_id( 'template' ); ?>"><strong><?php _e( 'Template', 'jrinstaslider' ); ?></strong>
|
254 |
<select class="widefat" name="<?php echo $this->get_field_name( 'template' ); ?>" id="<?php echo $this->get_field_id( 'template' ); ?>">
|
289 |
<select class="widefat" name="<?php echo $this->get_field_name( 'images_link' ); ?>" id="<?php echo $this->get_field_id( 'images_link' ); ?>">
|
290 |
<option value="image_url" <?php selected( $instance['images_link'], 'image_url', true); ?>><?php _e( 'Instagram Image', 'jrinstaslider' ); ?></option>
|
291 |
<option class="<?php if ( 'hashtag' == $instance['search_for'] ) echo 'hidden'; ?>" value="user_url" <?php selected( $instance['images_link'], 'user_url', true); ?>><?php _e( 'Instagram Profile', 'jrinstaslider' ); ?></option>
|
292 |
+
<option class="<?php if ( ( !$instance['attachment'] ) || 'hashtag' == $instance['search_for'] ) echo 'hidden'; ?>" value="local_image_url" <?php selected( $instance['images_link'], 'local_image_url', true); ?>><?php _e( 'Locally Saved Image', 'jrinstaslider' ); ?></option>
|
293 |
+
<option class="<?php if ( ( !$instance['attachment'] ) || 'hashtag' == $instance['search_for'] ) echo 'hidden'; ?>" value="attachment" <?php selected( $instance['images_link'], 'attachment', true); ?>><?php _e( 'Attachment Page', 'jrinstaslider' ); ?></option>
|
294 |
<option value="custom_url" <?php selected( $instance['images_link'], 'custom_url', true ); ?>><?php _e( 'Custom Link', 'jrinstaslider' ); ?></option>
|
295 |
<option value="none" <?php selected( $instance['images_link'], 'none', true); ?>><?php _e( 'None', 'jrinstaslider' ); ?></option>
|
296 |
</select>
|
325 |
<label for="<?php echo $this->get_field_id( 'image_link_class' ); ?>"><?php _e( 'Image Link class', 'jrinstaslider' ); ?>:</label>
|
326 |
<input class="widefat" id="<?php echo $this->get_field_id( 'image_link_class' ); ?>" name="<?php echo $this->get_field_name( 'image_link_class' ); ?>" value="<?php echo $instance['image_link_class']; ?>" />
|
327 |
<span class="jr-description"><?php _e( 'Usefull if you are using jQuery lightbox plugins to open links', 'jrinstaslider' ); ?></span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
</p>
|
329 |
+
<p><strong><?php _e( 'Disable Pinning:', 'jrinstaslider' ); ?></strong>
|
330 |
+
<label class="switch" for="<?php echo $this->get_field_id( 'no_pin' ); ?>">
|
331 |
+
<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'] ); ?> /><span class="slider round"></span></label>
|
332 |
+
<br><span class="jr-description"><?php _e( 'Disable pinning for Pinterest on all images from this widget!', 'jrinstaslider') ?></span>
|
333 |
+
</p>
|
334 |
+
</div>
|
335 |
+
<div class="jr-slider-options <?php if ( 'thumbs' == $instance['template'] || 'thumbs-no-border' == $instance['template'] ) echo 'hidden'; ?>">
|
336 |
+
<h4 class="jr-advanced-title"><?php _e( 'Advanced Slider Options', 'jrinstaslider'); ?></h4>
|
337 |
+
<p>
|
338 |
+
<?php _e( 'Slider Navigation Controls:', 'jrinstaslider' ); ?><br>
|
339 |
+
<label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'controls' ); ?>" name="<?php echo $this->get_field_name( 'controls' ); ?>" value="prev_next" <?php checked( 'prev_next', $instance['controls'] ); ?> /> <?php _e( 'Prev & Next', 'jrinstaslider' ); ?></label>
|
340 |
+
<label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'controls' ); ?>" name="<?php echo $this->get_field_name( 'controls' ); ?>" value="numberless" <?php checked( 'numberless', $instance['controls'] ); ?> /> <?php _e( 'Dotted', 'jrinstaslider' ); ?></label>
|
341 |
+
<label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'controls' ); ?>" name="<?php echo $this->get_field_name( 'controls' ); ?>" value="none" <?php checked( 'none', $instance['controls'] ); ?> /> <?php _e( 'No Navigation', 'jrinstaslider' ); ?></label>
|
342 |
+
</p>
|
343 |
+
<p>
|
344 |
+
<?php _e( 'Slider Animation:', 'jrinstaslider' ); ?><br>
|
345 |
+
<label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'animation' ); ?>" name="<?php echo $this->get_field_name( 'animation' ); ?>" value="slide" <?php checked( 'slide', $instance['animation'] ); ?> /> <?php _e( 'Slide', 'jrinstaslider' ); ?></label>
|
346 |
+
<label class="jr-radio"><input type="radio" id="<?php echo $this->get_field_id( 'animation' ); ?>" name="<?php echo $this->get_field_name( 'animation' ); ?>" value="fade" <?php checked( 'fade', $instance['animation'] ); ?> /> <?php _e( 'Fade', 'jrinstaslider' ); ?></label>
|
347 |
+
</p>
|
348 |
+
<p>
|
349 |
+
<label for="<?php echo $this->get_field_id( 'caption_words' ); ?>"><?php _e( 'Number of words in caption:', 'jrinstaslider' ); ?>
|
350 |
+
<input class="small-text" id="<?php echo $this->get_field_id( 'caption_words' ); ?>" name="<?php echo $this->get_field_name( 'caption_words' ); ?>" value="<?php echo $instance['caption_words']; ?>" />
|
351 |
+
</label>
|
352 |
+
</p>
|
353 |
+
<p>
|
354 |
+
<label for="<?php echo $this->get_field_id( 'slidespeed' ); ?>"><?php _e( 'Slide Speed:', 'jrinstaslider' ); ?>
|
355 |
+
<input class="small-text" id="<?php echo $this->get_field_id( 'slidespeed' ); ?>" name="<?php echo $this->get_field_name( 'slidespeed' ); ?>" value="<?php echo $instance['slidespeed']; ?>" />
|
356 |
+
<span><?php _e('milliseconds', 'jrinstaslider'); ?></span>
|
357 |
+
<span class='jr-description'><?php _e('1000 milliseconds = 1 second', 'jrinstaslider'); ?></span>
|
358 |
+
</label>
|
359 |
+
</p>
|
360 |
+
<p>
|
361 |
+
<label for="<?php echo $this->get_field_id('description'); ?>"><?php _e( 'Slider Text Description:', 'jrinstaslider' ); ?></label>
|
362 |
+
<select size=3 class='widefat' id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>[]" multiple="multiple">
|
363 |
+
<option class="<?php if ( 'hashtag' == $instance['search_for'] ) echo 'hidden'; ?>" value='username' <?php $this->selected( $instance['description'], 'username' ); ?>><?php _e( 'Username', 'jrinstaslider'); ?></option>
|
364 |
+
<option value='time'<?php $this->selected( $instance['description'], 'time' ); ?>><?php _e( 'Time', 'jrinstaslider'); ?></option>
|
365 |
+
<option value='caption'<?php $this->selected( $instance['description'], 'caption' ); ?>><?php _e( 'Caption', 'jrinstaslider'); ?></option>
|
366 |
+
</select>
|
367 |
+
<span class="jr-description"><?php _e( 'Hold ctrl and click the fields you want to show/hide on your slider. Leave all unselected to hide them all. Default all selected.', 'jrinstaslider') ?></span>
|
368 |
+
</p>
|
369 |
+
</div>
|
370 |
</div>
|
371 |
+
<?php $widget_id = preg_replace( '/[^0-9]/', '', $this->id ); if ( $widget_id != '' ) : ?>
|
372 |
+
<p>
|
373 |
+
<label for="jr_insta_shortcode"><?php _e('Shortcode of this Widget:', 'jrinstaslider'); ?></label>
|
374 |
+
<input id="jr_insta_shortcode" onclick="this.setSelectionRange(0, this.value.length)" type="text" class="widefat" value="[jr_instagram id="<?php echo $widget_id ?>"]" readonly="readonly" style="border:none; color:black; font-family:monospace;">
|
375 |
+
<span class="jr-description"><?php _e( 'Use this shortcode in any page or post to display images with this widget configuration!', 'jrinstaslider') ?></span>
|
376 |
+
</p>
|
377 |
+
<?php endif; ?>
|
378 |
+
<div class="jr-advanced-input">
|
379 |
+
<div class="jr-image-options">
|
380 |
+
<h4 class="jr-advanced-title"><?php _e( 'Help us, help you!', 'jrinstaslider'); ?></h4>
|
381 |
+
<p><strong><?php _e( 'Show "Powered by Link"', 'jrinstaslider' ); ?></strong>
|
382 |
+
<label class="switch" for="<?php echo $this->get_field_id( 'support_author' ); ?>">
|
383 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'support_author' ); ?>" name="<?php echo $this->get_field_name( 'support_author' ); ?>" type="checkbox" value="1" <?php checked( '1', $instance['support_author'] ); ?> /><span class="slider round"></span></label>
|
384 |
+
<br><span class="jr-description"><?php _e( 'When enabled, the author is notified and a backlink website is visible at the bottom of the plugin. <br> <strong>If you enable this option you will have privileged support from our team!</strong>', 'jrinstaslider') ?></span>
|
385 |
+
</p>
|
386 |
+
<a target="_blank" title="Buy me movie tickets!" href="https://goo.gl/MpqlUU"><p class="donate"><span></span>Buy me movie tickets!</p></a>
|
387 |
+
</div></div>
|
388 |
+
</div><br>
|
389 |
+
<?php
|
390 |
}
|
391 |
|
392 |
/**
|
404 |
}
|
405 |
}
|
406 |
|
407 |
+
|
408 |
/**
|
409 |
* Add shorcode function
|
410 |
* @param array $atts shortcode attributes
|
420 |
}
|
421 |
}
|
422 |
|
423 |
+
|
424 |
+
/**
|
425 |
+
* Cron Trigger Function
|
426 |
+
* @param [type] $username [description]
|
427 |
+
* @param [type] $refresh_hour [description]
|
428 |
+
* @param [type] $images [description]
|
429 |
+
* @return [type] [description]
|
430 |
+
*/
|
431 |
+
public function jr_cron_trigger( $username, $refresh_hour, $images ) {
|
432 |
+
$search_for= array();
|
433 |
+
$search_for['username'] = $username;
|
434 |
+
$this->instagram_data( $search_for, $refresh_hour, $images, true );
|
435 |
+
}
|
436 |
+
|
437 |
+
|
438 |
/**
|
439 |
* Echoes the Display Instagram Images method
|
440 |
*
|
446 |
echo $this->display_images( $args );
|
447 |
}
|
448 |
|
449 |
+
|
450 |
/**
|
451 |
* Runs the query for images and returns the html
|
452 |
*
|
459 |
$username = isset( $args['username'] ) && !empty( $args['username'] ) ? $args['username'] : false;
|
460 |
$hashtag = isset( $args['hashtag'] ) && !empty( $args['hashtag'] ) ? str_replace( '#', '', $args['hashtag'] ) : false;
|
461 |
$blocked_users = isset( $args['blocked_users'] ) && !empty( $args['blocked_users'] ) ? $args['blocked_users'] : false;
|
|
|
462 |
$attachment = isset( $args['attachment'] ) ? true : false;
|
463 |
$template = isset( $args['template'] ) ? $args['template'] : 'slider';
|
464 |
$orderby = isset( $args['orderby'] ) ? $args['orderby'] : 'rand';
|
477 |
$slidespeed = isset( $args['slidespeed'] ) ? $args['slidespeed'] : 7000;
|
478 |
$description = isset( $args['description'] ) ? $args['description'] : array();
|
479 |
$widget_id = isset( $args['widget_id'] ) ? $args['widget_id'] : preg_replace( '/[^0-9]/', '', $this->id );
|
480 |
+
$powered_by_link = isset( $args['support_author'] ) ? true : false;
|
481 |
|
482 |
if ( !empty( $description ) && !is_array( $description ) ) {
|
483 |
$description = explode( ',', $description );
|
492 |
$search_for['username'] = $username;
|
493 |
}
|
494 |
|
495 |
+
if ( $refresh_hour == 0 ) {
|
496 |
$refresh_hour = 5;
|
497 |
}
|
498 |
|
499 |
$template_args = array(
|
500 |
'search_for' => $search,
|
|
|
501 |
'attachment' => $attachment,
|
502 |
+
'image_size' => $image_size,
|
503 |
'link_rel' => $image_link_rel,
|
504 |
'link_class' => $image_link_class,
|
505 |
'no_pin' => $no_pin,
|
506 |
'caption_words' => $caption_words
|
507 |
+
);
|
508 |
|
509 |
$images_div_class = 'jr-insta-thumb';
|
510 |
$ul_class = ( $template == 'thumbs-no-border' ) ? 'thumbnails no-border jr_col_' . $columns : 'thumbnails jr_col_' . $columns;
|
534 |
"</script>" . "\n";
|
535 |
} else {
|
536 |
$images_div_class = 'pllexislider pllexislider-overlay instaslider-nr-'. $widget_id;
|
537 |
+
$slider_script =
|
538 |
"<script type='text/javascript'>" . "\n" .
|
539 |
" jQuery(document).ready(function($) {" . "\n" .
|
540 |
" $('.instaslider-nr-{$widget_id}').pllexislider({" . "\n" .
|
558 |
" });" . "\n" .
|
559 |
"</script>" . "\n";
|
560 |
}
|
561 |
+
}
|
562 |
|
563 |
$images_div = "<div class='{$images_div_class}'>\n";
|
564 |
$images_ul = "<ul class='no-bullet {$ul_class}'>\n";
|
565 |
|
566 |
$output = __( 'No images found! <br> Try some other hashtag or username', 'jrinstaslider' );
|
567 |
|
568 |
+
if ( ( $search == 'user' && $attachment ) ) {
|
569 |
+
|
570 |
+
if ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ) {
|
571 |
+
$this->instagram_data( $search_for, $refresh_hour, $images_number, true );
|
572 |
+
} else {
|
573 |
+
if ( !wp_next_scheduled( 'jr_insta_cron', array( $search_for['username'], $refresh_hour, $images_number ) ) ) {
|
574 |
+
wp_schedule_single_event( time() + 20, 'jr_insta_cron', array( $search_for['username'], $refresh_hour, $images_number ) );
|
575 |
+
}
|
576 |
+
}
|
577 |
+
|
578 |
+
$opt_name = 'jr_insta_' . md5( $search . '_' . $search_for['username'] );
|
579 |
+
$attachment_ids = (array) get_option( $opt_name );
|
580 |
|
581 |
$query_args = array(
|
582 |
'post_type' => 'attachment',
|
583 |
'post_status' => 'inherit',
|
584 |
'post_mime_type' => 'image',
|
585 |
+
'posts_per_page' => $images_number,
|
|
|
586 |
'no_found_rows' => true
|
587 |
+
);
|
588 |
|
589 |
if ( $orderby != 'rand' ) {
|
590 |
|
595 |
$query_args['orderby'] = 'meta_value_num';
|
596 |
$query_args['order'] = $orderby[1];
|
597 |
}
|
598 |
+
|
599 |
+
if ( isset( $attachment_ids['saved_images'] ) ) {
|
600 |
+
|
601 |
+
$query_args['post__in'] = $attachment_ids['saved_images'];
|
602 |
+
|
603 |
+
} else {
|
604 |
+
|
605 |
$query_args['meta_query'] = array(
|
606 |
array(
|
607 |
'key' => 'jr_insta_username',
|
608 |
'value' => $username,
|
609 |
'compare' => '='
|
610 |
+
)
|
611 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
612 |
}
|
613 |
+
|
614 |
$instagram_images = new WP_Query( $query_args );
|
615 |
|
616 |
+
if ( $instagram_images->have_posts() ) {
|
617 |
+
|
618 |
$output = $slider_script . $images_div . $images_ul;
|
619 |
+
|
620 |
while ( $instagram_images->have_posts() ) : $instagram_images->the_post();
|
|
|
|
|
621 |
|
622 |
+
$id = get_the_id();
|
623 |
+
|
624 |
+
if ( 'image_url' == $images_link ) {
|
625 |
+
$template_args['link_to'] = get_post_meta( $id, 'jr_insta_link', true );
|
626 |
+
} elseif ( 'user_url' == $images_link ) {
|
627 |
+
$template_args['link_to'] = 'https://www.instagram.com/' . $username . '/';
|
628 |
+
} elseif ( 'local_image_url' == $images_link ) {
|
629 |
+
$template_args['link_to'] = wp_get_attachment_url( $id );
|
630 |
+
} elseif ( 'attachment' == $images_link ) {
|
631 |
+
$template_args['link_to'] = get_permalink( $id );
|
632 |
+
} elseif ( 'custom_url' == $images_link ) {
|
633 |
+
$template_args['link_to'] = $custom_url;
|
634 |
+
}
|
635 |
|
636 |
+
$output .= $this->get_template( $template, $template_args );
|
637 |
|
638 |
endwhile;
|
639 |
|
640 |
+
$output .= "</ul>\n</div>" . $this->powered_by_link( $powered_by_link );
|
641 |
+
|
642 |
+
} else {
|
643 |
+
|
644 |
+
$images_data = $this->instagram_data( $search_for, $refresh_hour, $images_number, false );
|
645 |
+
|
646 |
+
if ( is_array( $images_data ) && !empty( $images_data ) ) {
|
647 |
+
|
648 |
+
if ( $orderby != 'rand' ) {
|
649 |
+
|
650 |
+
$func = $orderby[0] == 'date' ? 'sort_timestamp_' . $orderby[1] : 'sort_popularity_' . $orderby[1];
|
651 |
+
|
652 |
+
usort( $images_data, array( $this, $func ) );
|
653 |
+
|
654 |
+
} else {
|
655 |
+
|
656 |
+
shuffle( $images_data );
|
657 |
+
}
|
658 |
+
|
659 |
+
$output = $slider_script . $images_div . $images_ul;
|
660 |
+
|
661 |
+
foreach ( $images_data as $image_data ) {
|
662 |
+
|
663 |
+
if ( 'image_url' == $images_link ) {
|
664 |
+
$template_args['link_to'] = $image_data['link'];
|
665 |
+
} elseif ( 'user_url' == $images_link ) {
|
666 |
+
$template_args['link_to'] = 'https://www.instagram.com/' . $username . '/';
|
667 |
+
} elseif ( 'custom_url' == $images_link ) {
|
668 |
+
$template_args['link_to'] = $custom_url;
|
669 |
+
}
|
670 |
+
|
671 |
+
if ( $image_size == 'jr_insta_square' ) {
|
672 |
+
$template_args['image'] = $image_data['url_thumbnail'];
|
673 |
+
} elseif( $image_size == 'full' ) {
|
674 |
+
$template_args['image'] = $image_data['url'];
|
675 |
+
} else {
|
676 |
+
$template_args['image'] = $image_data['url'];
|
677 |
+
}
|
678 |
+
|
679 |
+
$template_args['caption'] = $image_data['caption'];
|
680 |
+
$template_args['timestamp'] = $image_data['timestamp'];
|
681 |
+
$template_args['username'] = $image_data['username'];
|
682 |
+
$template_args['attachment'] = false;
|
683 |
+
|
684 |
+
$output .= $this->get_template( $template, $template_args );
|
685 |
+
}
|
686 |
+
|
687 |
+
$output .= "</ul>\n</div>" . $this->powered_by_link( $powered_by_link );
|
688 |
+
}
|
689 |
+
|
690 |
}
|
691 |
|
692 |
wp_reset_postdata();
|
736 |
$output .= $this->get_template( $template, $template_args );
|
737 |
}
|
738 |
|
739 |
+
$output .= "</ul>\n</div>" . $this->powered_by_link( $powered_by_link );
|
740 |
}
|
741 |
}
|
742 |
|
757 |
|
758 |
$link_to = isset( $args['link_to'] ) ? $args['link_to'] : false;
|
759 |
|
760 |
+
if ( ( $args['search_for'] == 'user' && $args['attachment'] !== true ) || $args['search_for'] == 'hashtag' ) {
|
761 |
$caption = $args['caption'];
|
762 |
$time = $args['timestamp'];
|
763 |
$username = $args['username'];
|
799 |
|
800 |
$output .= "<li>";
|
801 |
|
802 |
+
$output .= $image_output;
|
803 |
|
804 |
+
if ( is_array( $args['description'] ) && count( $args['description'] ) >= 1 ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
805 |
|
806 |
+
$output .= "<div class='jr-insta-datacontainer'>\n";
|
807 |
+
|
808 |
+
if ( $time && in_array( 'time', $args['description'] ) ) {
|
809 |
+
$time = human_time_diff( $time );
|
810 |
+
$output .= "<span class='jr-insta-time'>{$time} ago</span>\n";
|
811 |
+
}
|
812 |
+
if ( in_array( 'username', $args['description'] ) && $username ) {
|
813 |
+
$output .= "<span class='jr-insta-username'>by <a rel='nofollow' href='https://www.instagram.com/{$username}/' target='_blank'>{$username}</a></span>\n";
|
814 |
+
}
|
815 |
|
816 |
+
if ( $caption != '' && in_array( 'caption', $args['description'] ) ) {
|
817 |
+
$caption = preg_replace( '/@([a-z0-9_]+)/i', ' <a href="https://www.instagram.com/$1/" rel="nofollow" target="_blank">@$1</a> ', $caption );
|
818 |
+
$caption = preg_replace( '/\#([a-zA-Z0-9_-]+)/i', ' <a href="https://www.instagram.com/explore/tags/$1/" rel="nofollow" target="_blank">$0</a> ', $caption);
|
819 |
+
$output .= "<span class='jr-insta-caption'>{$caption}</span>\n";
|
820 |
}
|
821 |
|
822 |
+
$output .= "</div>\n";
|
823 |
+
}
|
824 |
+
|
825 |
$output .= "</li>";
|
826 |
+
|
827 |
// Template : Slider with text Overlay on mouse over
|
828 |
} elseif ( $template == 'slider-overlay' ) {
|
829 |
|
830 |
$output .= "<li>";
|
831 |
|
832 |
+
$output .= $image_output;
|
833 |
|
834 |
+
if ( is_array( $args['description'] ) && count( $args['description'] ) >= 1 ) {
|
|
|
|
|
835 |
|
836 |
+
$output .= "<div class='jr-insta-wrap'>\n";
|
837 |
|
838 |
+
$output .= "<div class='jr-insta-datacontainer'>\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
839 |
|
840 |
+
if ( $time && in_array( 'time', $args['description'] ) ) {
|
841 |
+
$time = human_time_diff( $time );
|
842 |
+
$output .= "<span class='jr-insta-time'>{$time} ago</span>\n";
|
843 |
+
}
|
|
|
844 |
|
845 |
+
if ( in_array( 'username', $args['description'] ) && $username ) {
|
846 |
+
$output .= "<span class='jr-insta-username'>by <a rel='nofollow' target='_blank' href='https://www.instagram.com/{$username}/'>{$username}</a></span>\n";
|
847 |
+
}
|
848 |
|
849 |
+
if ( $caption != '' && in_array( 'caption', $args['description'] ) ) {
|
850 |
+
$caption = preg_replace( '/@([a-z0-9_]+)/i', ' <a href="https://www.instagram.com/$1/" rel="nofollow" target="_blank">@$1</a> ', $caption );
|
851 |
+
$caption = preg_replace( '/\#([a-zA-Z0-9_-]+)/i', ' <a href="https://www.instagram.com/explore/tags/$1/" rel="nofollow" target="_blank">$0</a> ', $caption);
|
852 |
+
$output .= "<span class='jr-insta-caption'>{$caption}</span>\n";
|
853 |
}
|
854 |
+
|
855 |
+
$output .= "</div>\n";
|
856 |
+
|
857 |
+
$output .= "</div>\n";
|
858 |
+
}
|
859 |
|
860 |
$output .= "</li>";
|
861 |
+
|
862 |
// Template : Thumbnails no text
|
863 |
} elseif ( $template == 'thumbs' || $template == 'thumbs-no-border' ) {
|
864 |
|
874 |
return $output;
|
875 |
}
|
876 |
|
877 |
+
|
878 |
/**
|
879 |
* Trigger refresh for new data
|
880 |
* @param bolean $instaData
|
886 |
|
887 |
$trigger = 0;
|
888 |
|
889 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
890 |
+
return false;
|
891 |
+
}
|
892 |
+
|
893 |
if ( false === $instaData ) {
|
894 |
$trigger = 1;
|
895 |
}
|
896 |
+
|
897 |
+
|
898 |
+
if ( isset( $old_args['saved_images'] ) ) {
|
899 |
+
unset($old_args['saved_images']);
|
900 |
+
}
|
901 |
+
|
902 |
+
if ( isset( $old_args['deleted_images'] ) ) {
|
903 |
+
unset($old_args['deleted_images']);
|
904 |
+
}
|
905 |
|
906 |
if ( is_array( $old_args ) && is_array( $new_args ) && array_diff( $old_args, $new_args ) !== array_diff( $new_args, $old_args ) ) {
|
907 |
$trigger = 1;
|
914 |
return false;
|
915 |
}
|
916 |
|
917 |
+
|
918 |
+
/**
|
919 |
+
* Show powered by link at the end of the plugin
|
920 |
+
* @param [type] $support_author [description]
|
921 |
+
* @return [type] [description]
|
922 |
+
*/
|
923 |
+
function powered_by_link( $support_author ) {
|
924 |
+
|
925 |
+
if ( $support_author ) {
|
926 |
+
|
927 |
+
$link = $this->domain_data();
|
928 |
+
|
929 |
+
if ( isset( $link['text'] ) && !empty( $link['text'] ) && isset( $link['domain'] ) && !empty( $link['domain'] ) ) {
|
930 |
+
$link = '<div style="clear:both;text-align:right;font-size:10px;" ><a href="'.$link['domain'].'" target="_blank">'.$link['text'].'</a></div>';
|
931 |
+
} else if ( isset( $link['text'] ) && !empty( $link['text'] ) ) {
|
932 |
+
$link = '<div style="clear:both;text-align:right;font-size:10px;" >'.$link['text'].'</div>';
|
933 |
+
} else {
|
934 |
+
$link = '';
|
935 |
+
}
|
936 |
+
|
937 |
+
return $link;
|
938 |
+
}
|
939 |
+
return false;
|
940 |
+
}
|
941 |
+
|
942 |
+
|
943 |
/**
|
944 |
* Stores the fetched data from instagram in WordPress DB using transients
|
945 |
*
|
973 |
'cache_hours' => $cache_hours,
|
974 |
'nr_images' => $nr_images,
|
975 |
'attachment' => $attachment
|
976 |
+
);
|
977 |
|
978 |
if ( true === $this->trigger_refresh_data( $instaData, $old_opts, $new_opts ) ) {
|
979 |
|
1067 |
if ( ( $search == 'hashtag' ) || ( $search == 'user' && !$attachment ) ) {
|
1068 |
|
1069 |
$instaData[] = $image_data;
|
1070 |
+
|
1071 |
} else {
|
1072 |
+
|
1073 |
if ( isset( $old_opts['saved_images'][$image_data['id']] ) ) {
|
1074 |
|
1075 |
if ( is_string( get_post_status( $old_opts['saved_images'][$image_data['id']] ) ) ) {
|
1077 |
$this->update_wp_attachment( $old_opts['saved_images'][$image_data['id']], $image_data );
|
1078 |
|
1079 |
$instaData[$image_data['id']] = $old_opts['saved_images'][$image_data['id']];
|
1080 |
+
}
|
|
|
|
|
|
|
|
|
1081 |
|
1082 |
} else {
|
1083 |
|
1088 |
$old_opts['saved_images'][$image_data['id']] = $id;
|
1089 |
|
1090 |
$instaData[$image_data['id']] = $id;
|
1091 |
+
|
1092 |
} else {
|
1093 |
|
1094 |
return $id;
|
1120 |
return $instaData;
|
1121 |
}
|
1122 |
|
1123 |
+
/**
|
1124 |
+
* Remove Duplicates
|
1125 |
+
* @return [type] [description]
|
1126 |
+
*/
|
1127 |
+
private function clean_duplicates( $username ) {
|
1128 |
+
|
1129 |
+
$savedinsta_args = array(
|
1130 |
+
'post_type' => 'attachment',
|
1131 |
+
'post_status' => 'inherit',
|
1132 |
+
'post_mime_type' => 'image',
|
1133 |
+
'orderby' => 'rand',
|
1134 |
+
'posts_per_page' => -1,
|
1135 |
+
'meta_query' => array(
|
1136 |
+
array(
|
1137 |
+
'key' => 'jr_insta_username',
|
1138 |
+
'compare' => '=',
|
1139 |
+
'value' => $username
|
1140 |
+
),
|
1141 |
+
),
|
1142 |
+
);
|
1143 |
+
|
1144 |
+
$savedinsta = new WP_Query( $savedinsta_args );
|
1145 |
+
|
1146 |
+
$opt_name = 'jr_insta_' . md5( 'user' . '_' . $username );
|
1147 |
+
|
1148 |
+
$attachment_ids = (array) get_option( $opt_name );
|
1149 |
+
|
1150 |
+
$deleted_count = 0;
|
1151 |
+
|
1152 |
+
foreach ( $savedinsta->posts as $post ) {
|
1153 |
+
|
1154 |
+
if ( !in_array( $post->ID, $attachment_ids['saved_images'] ) ) {
|
1155 |
+
|
1156 |
+
if ( false !== wp_delete_attachment( $post->ID, true ) ) {
|
1157 |
+
$deleted_count++;
|
1158 |
+
}
|
1159 |
+
}
|
1160 |
+
}
|
1161 |
+
|
1162 |
+
wp_reset_postdata();
|
1163 |
+
|
1164 |
+
return $deleted_count;
|
1165 |
+
}
|
1166 |
+
|
1167 |
+
/**
|
1168 |
+
* Ajax Call to unblock images
|
1169 |
+
* @return void
|
1170 |
+
*/
|
1171 |
+
public function delete_dupes() {
|
1172 |
+
|
1173 |
+
if (function_exists('check_ajax_referer')) {
|
1174 |
+
check_ajax_referer( 'jr_delete_instagram_dupes' );
|
1175 |
+
}
|
1176 |
+
|
1177 |
+
$post = $_POST;
|
1178 |
+
$return = array(
|
1179 |
+
'deleted' => $this->clean_duplicates( $post['username'] )
|
1180 |
+
);
|
1181 |
+
|
1182 |
+
wp_send_json( $return );
|
1183 |
+
}
|
1184 |
|
1185 |
/**
|
1186 |
* Get Instagram Ids from Usernames into array
|
1202 |
}
|
1203 |
|
1204 |
$response = wp_remote_get( 'https://www.instagram.com/' . trim( $user ), array( 'sslverify' => false, 'timeout' => 60 ) );
|
1205 |
+
|
1206 |
if ( is_wp_error( $response ) ) {
|
1207 |
|
1208 |
return $response->get_error_message();
|
1209 |
}
|
1210 |
+
|
1211 |
if ( $response['response']['code'] == 200 ) {
|
1212 |
|
1213 |
$json = str_replace( 'window._sharedData = ', '', strstr( $response['body'], 'window._sharedData = ' ) );
|
1234 |
if ( $results && is_array( $results ) ) {
|
1235 |
|
1236 |
$user_id = isset( $results['entry_data']['ProfilePage'][0]['user']['id'] ) ? $results['entry_data']['ProfilePage'][0]['user']['id'] : false;
|
1237 |
+
|
1238 |
if ( $user_id ) {
|
1239 |
|
1240 |
$user_ids[$user] = $user_id;
|
1241 |
+
|
1242 |
set_transient( 'jr_insta_user_ids', $user_ids );
|
1243 |
}
|
1244 |
}
|
1278 |
*/
|
1279 |
private function save_wp_attachment( $image_data ) {
|
1280 |
|
|
|
|
|
|
|
1281 |
// Remove Instagram chace key from url
|
1282 |
$clean_url = esc_url( remove_query_arg( 'ig_cache_key', $image_data['url'] ) );
|
1283 |
|
1311 |
|
1312 |
$id = media_handle_sideload( $file_array, 0, NULL, array(
|
1313 |
'post_excerpt' => $image_data['caption']
|
1314 |
+
) );
|
1315 |
|
1316 |
// If error storing permanently, unlink
|
1317 |
if ( is_wp_error( $id ) ) {
|
1348 |
"label" => __( "Instagram Username" ),
|
1349 |
"input" => "html",
|
1350 |
"html" => "<span style='line-height:31px'><a target='_blank' href='https://www.instagram.com/{$instagram_username}/'>{$instagram_username}</a></span>"
|
1351 |
+
);
|
1352 |
|
1353 |
$instagram_link = get_post_meta( $post->ID, 'jr_insta_link', true );
|
1354 |
if ( !empty( $instagram_link ) ) {
|
1356 |
"label" => __( "Instagram Image" ),
|
1357 |
"input" => "html",
|
1358 |
"html" => "<span style='line-height:31px'><a target='_blank' href='{$instagram_link}'>{$instagram_link}</a></span>"
|
1359 |
+
);
|
1360 |
}
|
1361 |
|
1362 |
$instagram_date = get_post_meta( $post->ID, 'jr_insta_timestamp', true );
|
1366 |
"label" => __( "Posted on Instagram" ),
|
1367 |
"input" => "html",
|
1368 |
"html" => "<span style='line-height:31px'>{$instagram_date}</span>"
|
1369 |
+
);
|
1370 |
}
|
1371 |
}
|
1372 |
|
1402 |
}
|
1403 |
|
1404 |
/**
|
1405 |
+
* Plugin Data for better compatibility and Support
|
1406 |
+
*
|
|
|
1407 |
*/
|
1408 |
+
public function domain_data() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1409 |
|
1410 |
+
if ( false === $domain_data = get_transient( 'jr_domain_info' ) ) {
|
1411 |
+
|
1412 |
+
$theme = wp_get_theme();
|
1413 |
+
$domain = get_site_url();
|
1414 |
+
$plugin = self::VERSION;
|
1415 |
+
$url = 'http://jrwebstudio.com/wp-admin/admin-post.php';
|
1416 |
+
|
1417 |
+
$response = wp_safe_remote_post( $url, array(
|
1418 |
+
'method' => 'POST',
|
1419 |
+
'timeout' => 45,
|
1420 |
+
'redirection' => 5,
|
1421 |
+
'httpversion' => '1.1',
|
1422 |
+
'blocking' => true,
|
1423 |
+
'user-agent' => 'Mozilla/4.0',
|
1424 |
+
'headers' => array(),
|
1425 |
+
'cookies' => array(),
|
1426 |
+
'body' => array(
|
1427 |
+
'action' => 'insta_users',
|
1428 |
+
'domain' => $domain,
|
1429 |
+
'theme_name' => $theme->get( 'Name' ),
|
1430 |
+
'theme_version' => $theme->get( 'Version' ),
|
1431 |
+
'plugin_version' => $plugin,
|
1432 |
+
'timestamp' => time()
|
1433 |
+
)
|
1434 |
+
)
|
1435 |
+
);
|
1436 |
|
1437 |
+
if ( $response['response']['code'] == 200 ) {
|
1438 |
+
$domain_data = json_decode( wp_remote_retrieve_body( $response ), true );
|
1439 |
+
if ( is_array( $domain_data) && !empty( $domain_data) ) {
|
1440 |
+
set_transient( 'jr_domain_info', $domain_data, WEEK_IN_SECONDS );
|
1441 |
+
}
|
1442 |
+
}
|
1443 |
+
}
|
1444 |
|
1445 |
+
return $domain_data;
|
|
|
|
|
|
|
|
|
|
|
|
|
1446 |
}
|
1447 |
|
1448 |
/**
|
1455 |
* @return the sanitized input
|
1456 |
*/
|
1457 |
private function sanitize( $input ) {
|
1458 |
+
|
1459 |
if ( !empty( $input ) ) {
|
1460 |
$utf8_2byte = 0xC0 /*1100 0000*/ ;
|
1461 |
$utf8_2byte_bmask = 0xE0 /*1110 0000*/ ;
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: jetonr
|
|
3 |
Tags: instagram, slider, widget, images
|
4 |
Donate link: http://goo.gl/RZiu34
|
5 |
Requires at least: 3.5
|
6 |
-
Tested up to: 4.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -14,18 +14,17 @@ Instagram Slider Widget is a responsive slider widget that shows 12 latest image
|
|
14 |
|
15 |
|
16 |
= Features =
|
17 |
-
* Images from
|
18 |
* Display Images in Slider or Thumbnails
|
19 |
-
* No
|
20 |
-
* Link images to user profile, image
|
21 |
-
* Sort images
|
22 |
* For more info visit http://instagram.jrwebstudio.com
|
23 |
|
24 |
= Where can I get support =
|
25 |
-
I will try to respond on
|
26 |
-
* http://support.jrwebstudio.com/product/instagram-slider-widget/
|
27 |
|
28 |
-
= If you
|
29 |
|
30 |
== Installation ==
|
31 |
|
@@ -38,6 +37,7 @@ I will try to respond on wordpress.org asap but for faster reposnse use the link
|
|
38 |
= Requirements =
|
39 |
* PHP 5.2.0 or later
|
40 |
* Wordpress 3.5 or later
|
|
|
41 |
|
42 |
== Screenshots ==
|
43 |
1. Frontend Widget Slider
|
@@ -45,6 +45,12 @@ I will try to respond on wordpress.org asap but for faster reposnse use the link
|
|
45 |
3. Backend Configuration
|
46 |
|
47 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
= 1.3.3 =
|
49 |
* Fixed notification error message.
|
50 |
|
3 |
Tags: instagram, slider, widget, images
|
4 |
Donate link: http://goo.gl/RZiu34
|
5 |
Requires at least: 3.5
|
6 |
+
Tested up to: 4.7.2
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
14 |
|
15 |
|
16 |
= Features =
|
17 |
+
* Images from Instagram are imported as WordPress attachments
|
18 |
* Display Images in Slider or Thumbnails
|
19 |
+
* No API Key Needed
|
20 |
+
* Link images to user profile, image URL, locally saved image, attachment URL, custom URL or none
|
21 |
+
* Sort images Randomly, Popularity, Date
|
22 |
* For more info visit http://instagram.jrwebstudio.com
|
23 |
|
24 |
= Where can I get support =
|
25 |
+
I will try to respond to all on plugin support forum but users showing back-link on their website will be more privileged!
|
|
|
26 |
|
27 |
+
= If you like this plugin. Rate it and Donate =
|
28 |
|
29 |
== Installation ==
|
30 |
|
37 |
= Requirements =
|
38 |
* PHP 5.2.0 or later
|
39 |
* Wordpress 3.5 or later
|
40 |
+
* WordPress Cron must be enabled
|
41 |
|
42 |
== Screenshots ==
|
43 |
1. Frontend Widget Slider
|
45 |
3. Backend Configuration
|
46 |
|
47 |
== Changelog ==
|
48 |
+
= 1.4.0 =
|
49 |
+
* Fixed the issue where duplicate images were being inserted into Media Library
|
50 |
+
* Added a button in widget to remove previously created duplicate images
|
51 |
+
* Simplified the options to save images into media library
|
52 |
+
* Added an option to show backlink to help plugin development
|
53 |
+
|
54 |
= 1.3.3 =
|
55 |
* Fixed notification error message.
|
56 |
|