Version Description
- Fix. premium compatibility
- New. Instagram tag feed order by
Download this release
Release Info
Developer | quadlayers |
Plugin | Instagram Gallery |
Version | 2.9.4 |
Comparing to | |
See all releases |
Code changes from version 2.9.3 to 2.9.4
- assets/frontend/js/qligg.js +4 -4
- assets/frontend/js/qligg.min.js +1 -1
- includes/api.php +0 -340
- includes/api/api.php +61 -0
- includes/api/apiBASIC.php +346 -0
- includes/api/apiBusiness.php +119 -0
- includes/api/apiFeed.php +92 -0
- includes/api/apiPersonal.php +58 -0
- includes/apiFacebook.php +0 -218
- includes/apiInstagram.php +0 -161
- includes/compatibility.php +5 -5
- includes/controllers/AccountController.php +1 -1
- includes/controllers/FeedController.php +1 -1
- includes/frontend.php +7 -10
- includes/helpers.php +41 -24
- includes/models/Feed.php +1 -0
- includes/qligg.php +11 -19
- includes/view/backend/pages/accounts.php +2 -2
- includes/view/backend/pages/modals/feed/panel-feed-image-mask.php +2 -2
- includes/view/backend/pages/modals/feed/panel-feed-image-popup.php +2 -2
- includes/view/backend/pages/modals/feed/panel-feed.php +98 -78
- insta-gallery.php +2 -2
- readme.txt +5 -1
assets/frontend/js/qligg.js
CHANGED
@@ -260,7 +260,7 @@
|
|
260 |
counter = '<div class="mfp-icons"><div class="mfp-counter">' + (item.index + 1) + ' / ' + $('.insta-gallery-item', $wrap).length + '</div><a class="mfp-link" href="' + item.el.data('item').link + '" target="_blank" rel="noopener"><i class="qligg-icon-instagram"></i>Instagram</a></div>';
|
261 |
|
262 |
if (options.popup.profile) {
|
263 |
-
profile = '<div class="mfp-user"><img src="' + options.profile.profile_picture_url + '"><a href="' + options.profile.
|
264 |
}
|
265 |
|
266 |
if (options.popup.caption) {
|
@@ -271,15 +271,15 @@
|
|
271 |
date = '<div class="mfp-date">' + item.el.data('item').date + '</div>';
|
272 |
}
|
273 |
|
274 |
-
if (item.el.data('item').comments) {
|
275 |
comments = '<div class="mfp-comments"><i class="qligg-icon-comment"></i>' + item.el.data('item').comments + '</div>';
|
276 |
}
|
277 |
|
278 |
-
if (item.el.data('item').likes) {
|
279 |
likes = '<div class="mfp-likes"><i class="qligg-icon-heart"></i>' + item.el.data('item').likes + '</div>';
|
280 |
}
|
281 |
|
282 |
-
if (options.popup.likes) {
|
283 |
info = '<div class="mfp-info">' + likes + comments + date + '</div>';
|
284 |
}
|
285 |
|
260 |
counter = '<div class="mfp-icons"><div class="mfp-counter">' + (item.index + 1) + ' / ' + $('.insta-gallery-item', $wrap).length + '</div><a class="mfp-link" href="' + item.el.data('item').link + '" target="_blank" rel="noopener"><i class="qligg-icon-instagram"></i>Instagram</a></div>';
|
261 |
|
262 |
if (options.popup.profile) {
|
263 |
+
profile = '<div class="mfp-user"><img src="' + options.profile.profile_picture_url + '"><a href="https://www.instagram.com/' + options.profile.username + '" title="' + options.profile.name + '" target="_blank" rel="noopener">' + options.profile.username + '</a></div>';
|
264 |
}
|
265 |
|
266 |
if (options.popup.caption) {
|
271 |
date = '<div class="mfp-date">' + item.el.data('item').date + '</div>';
|
272 |
}
|
273 |
|
274 |
+
if (item.el.data('item').comments && options.popup.comments) {
|
275 |
comments = '<div class="mfp-comments"><i class="qligg-icon-comment"></i>' + item.el.data('item').comments + '</div>';
|
276 |
}
|
277 |
|
278 |
+
if (item.el.data('item').likes && options.popup.likes) {
|
279 |
likes = '<div class="mfp-likes"><i class="qligg-icon-heart"></i>' + item.el.data('item').likes + '</div>';
|
280 |
}
|
281 |
|
282 |
+
if (options.popup.likes || options.popup.comments) {
|
283 |
info = '<div class="mfp-info">' + likes + comments + date + '</div>';
|
284 |
}
|
285 |
|
assets/frontend/js/qligg.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function($){var swiper_index=0,$swipers={};function qligg_load_item_images($item,next_max_id){var $wrap=$(".insta-gallery-list",$item),$spinner=$(".insta-gallery-spinner",$item),feed=$item.data("feed");$.ajax({url:qligg.ajax_url,type:"post",timeout:3e4,data:{action:"qligg_load_item_images",next_max_id:next_max_id,feed:JSON.stringify(feed)},beforeSend:function(){$spinner.show()},success:function(response){if(!0!==response.success)return $wrap.append($(response.data)),void $spinner.hide();var $images=$(response.data);$wrap.append($images).trigger("qligg.loaded",[$images])},complete:function(){},error:function(jqXHR,textStatus){$spinner.hide(),console.log(textStatus)}})}$(".insta-gallery-feed").on("qligg.loaded",(function(e,images){var $item=$(e.delegateTarget),$wrap=$(".insta-gallery-list",$item),$spinner=$(".insta-gallery-spinner",$item),$button=$(".insta-gallery-button.load",$item),options=$item.data("feed"),total=$(images).length,loaded=0;total&&$wrap.find(".insta-gallery-image").load((function(e){++loaded>=total&&$wrap.trigger("qligg.imagesLoaded",[images])})),total<options.limit&&($spinner.hide(),setTimeout((function(){$button.fadeOut()}),300))})),$(".insta-gallery-feed").on("qligg.imagesLoaded",(function(e){var $item=$(e.delegateTarget),$spinner;$(".insta-gallery-spinner",$item).hide()})),$(".insta-gallery-feed[data-feed_layout=gallery]").on("qligg.imagesLoaded",(function(e,images){var $item;$(e.delegateTarget).addClass("loaded"),$(images).each((function(i,item){setTimeout((function(){$(item).addClass("ig-image-loaded")}),150+30*i)}))})),$(".insta-gallery-feed[data-feed_layout=carousel]").on("qligg.imagesLoaded",(function(e,images){var $item;$(e.delegateTarget).addClass("loaded"),$(images).each((function(i,item){$(item).addClass("ig-image-loaded")}))})),$(".insta-gallery-feed[data-feed_layout=carousel]").on("qligg.imagesLoaded",(function(e,images){var $item=$(e.delegateTarget),$swiper=$(".swiper-container",$item),options=$item.data("feed");options.carousel.slides=options.carousel.slidespv,swiper_index++,$swipers[swiper_index]=new Swiper($swiper,{loop:!0,autoHeight:!0,observer:!0,observeParents:!0,slidesPerView:1,spaceBetween:2,autoplay:!!options.carousel.autoplay&&{delay:parseInt(options.carousel.autoplay_interval)},pagination:{el:".swiper-pagination",dynamicBullets:!0,clickable:!0,type:"bullets"},navigation:{nextEl:".swiper-button-next",prevEl:".swiper-button-prev"},breakpoints:{320:{slidesPerView:2,spaceBetween:2},480:{spaceBetween:parseInt(options.spacing),slidesPerView:Math.min(2,parseInt(options.carousel.slides))},768:{spaceBetween:parseInt(options.spacing),slidesPerView:Math.min(3,parseInt(options.carousel.slides))},1024:{spaceBetween:parseInt(options.spacing),slidesPerView:parseInt(options.carousel.slides)}}})})),$(".insta-gallery-feed[data-feed_layout=masonry]").on("qligg.imagesLoaded",(function(e,images){var $item=$(e.delegateTarget),$wrap=$(".insta-gallery-list",$item);$wrap.data("masonry")?$wrap.masonry("appended",images,!1):$wrap.masonry({itemSelector:".insta-gallery-item",isResizable:!0,isAnimated:!1,transitionDuration:0,percentPosition:!0,columnWidth:".insta-gallery-item:last-child"})})),$(".insta-gallery-feed[data-feed_layout=masonry]").on("layoutComplete",(function(e,items){var $item;$(e.delegateTarget).addClass("loaded"),$(items).each((function(i,item){$(item.element).addClass("ig-image-loaded")}))})),$(".insta-gallery-feed").on("qligg.loaded",(function(e){var $item=$(e.delegateTarget),$wrap=$(".insta-gallery-list",$item),options=$item.data("feed");$(".insta-gallery-item .insta-gallery-icon.qligg-icon-instagram",$wrap).on("click",(function(e){e.stopPropagation()})),options.popup.display&&$(".insta-gallery-item",$wrap).magnificPopup({type:"inline",callbacks:{beforeOpen:function(){this.st.mainClass=this.st.mainClass+" qligg-mfp-wrap"},elementParse:function(item){var media="",profile="",counter="",caption="",info="",likes="",date="",comments="";media='<img src="'+item.el.data("item").images.standard+'"/>',counter='<div class="mfp-icons"><div class="mfp-counter">'+(item.index+1)+" / "+$(".insta-gallery-item",$wrap).length+'</div><a class="mfp-link" href="'+item.el.data("item").link+'" target="_blank" rel="noopener"><i class="qligg-icon-instagram"></i>Instagram</a></div>',options.popup.profile&&(profile='<div class="mfp-user"><img src="'+options.profile.profile_picture_url+'"><a href="'+options.profile.
|
1 |
+
!function($){var swiper_index=0,$swipers={};function qligg_load_item_images($item,next_max_id){var $wrap=$(".insta-gallery-list",$item),$spinner=$(".insta-gallery-spinner",$item),feed=$item.data("feed");$.ajax({url:qligg.ajax_url,type:"post",timeout:3e4,data:{action:"qligg_load_item_images",next_max_id:next_max_id,feed:JSON.stringify(feed)},beforeSend:function(){$spinner.show()},success:function(response){if(!0!==response.success)return $wrap.append($(response.data)),void $spinner.hide();var $images=$(response.data);$wrap.append($images).trigger("qligg.loaded",[$images])},complete:function(){},error:function(jqXHR,textStatus){$spinner.hide(),console.log(textStatus)}})}$(".insta-gallery-feed").on("qligg.loaded",(function(e,images){var $item=$(e.delegateTarget),$wrap=$(".insta-gallery-list",$item),$spinner=$(".insta-gallery-spinner",$item),$button=$(".insta-gallery-button.load",$item),options=$item.data("feed"),total=$(images).length,loaded=0;total&&$wrap.find(".insta-gallery-image").load((function(e){++loaded>=total&&$wrap.trigger("qligg.imagesLoaded",[images])})),total<options.limit&&($spinner.hide(),setTimeout((function(){$button.fadeOut()}),300))})),$(".insta-gallery-feed").on("qligg.imagesLoaded",(function(e){var $item=$(e.delegateTarget),$spinner;$(".insta-gallery-spinner",$item).hide()})),$(".insta-gallery-feed[data-feed_layout=gallery]").on("qligg.imagesLoaded",(function(e,images){var $item;$(e.delegateTarget).addClass("loaded"),$(images).each((function(i,item){setTimeout((function(){$(item).addClass("ig-image-loaded")}),150+30*i)}))})),$(".insta-gallery-feed[data-feed_layout=carousel]").on("qligg.imagesLoaded",(function(e,images){var $item;$(e.delegateTarget).addClass("loaded"),$(images).each((function(i,item){$(item).addClass("ig-image-loaded")}))})),$(".insta-gallery-feed[data-feed_layout=carousel]").on("qligg.imagesLoaded",(function(e,images){var $item=$(e.delegateTarget),$swiper=$(".swiper-container",$item),options=$item.data("feed");options.carousel.slides=options.carousel.slidespv,swiper_index++,$swipers[swiper_index]=new Swiper($swiper,{loop:!0,autoHeight:!0,observer:!0,observeParents:!0,slidesPerView:1,spaceBetween:2,autoplay:!!options.carousel.autoplay&&{delay:parseInt(options.carousel.autoplay_interval)},pagination:{el:".swiper-pagination",dynamicBullets:!0,clickable:!0,type:"bullets"},navigation:{nextEl:".swiper-button-next",prevEl:".swiper-button-prev"},breakpoints:{320:{slidesPerView:2,spaceBetween:2},480:{spaceBetween:parseInt(options.spacing),slidesPerView:Math.min(2,parseInt(options.carousel.slides))},768:{spaceBetween:parseInt(options.spacing),slidesPerView:Math.min(3,parseInt(options.carousel.slides))},1024:{spaceBetween:parseInt(options.spacing),slidesPerView:parseInt(options.carousel.slides)}}})})),$(".insta-gallery-feed[data-feed_layout=masonry]").on("qligg.imagesLoaded",(function(e,images){var $item=$(e.delegateTarget),$wrap=$(".insta-gallery-list",$item);$wrap.data("masonry")?$wrap.masonry("appended",images,!1):$wrap.masonry({itemSelector:".insta-gallery-item",isResizable:!0,isAnimated:!1,transitionDuration:0,percentPosition:!0,columnWidth:".insta-gallery-item:last-child"})})),$(".insta-gallery-feed[data-feed_layout=masonry]").on("layoutComplete",(function(e,items){var $item;$(e.delegateTarget).addClass("loaded"),$(items).each((function(i,item){$(item.element).addClass("ig-image-loaded")}))})),$(".insta-gallery-feed").on("qligg.loaded",(function(e){var $item=$(e.delegateTarget),$wrap=$(".insta-gallery-list",$item),options=$item.data("feed");$(".insta-gallery-item .insta-gallery-icon.qligg-icon-instagram",$wrap).on("click",(function(e){e.stopPropagation()})),options.popup.display&&$(".insta-gallery-item",$wrap).magnificPopup({type:"inline",callbacks:{beforeOpen:function(){this.st.mainClass=this.st.mainClass+" qligg-mfp-wrap"},elementParse:function(item){var media="",profile="",counter="",caption="",info="",likes="",date="",comments="";media='<img src="'+item.el.data("item").images.standard+'"/>',counter='<div class="mfp-icons"><div class="mfp-counter">'+(item.index+1)+" / "+$(".insta-gallery-item",$wrap).length+'</div><a class="mfp-link" href="'+item.el.data("item").link+'" target="_blank" rel="noopener"><i class="qligg-icon-instagram"></i>Instagram</a></div>',options.popup.profile&&(profile='<div class="mfp-user"><img src="'+options.profile.profile_picture_url+'"><a href="https://www.instagram.com/'+options.profile.username+'" title="'+options.profile.name+'" target="_blank" rel="noopener">'+options.profile.username+"</a></div>"),options.popup.caption&&(caption='<div class="mfp-caption">'+item.el.data("item").caption+"</div>"),item.el.data("item").date&&(date='<div class="mfp-date">'+item.el.data("item").date+"</div>"),item.el.data("item").comments&&options.popup.comments&&(comments='<div class="mfp-comments"><i class="qligg-icon-comment"></i>'+item.el.data("item").comments+"</div>"),item.el.data("item").likes&&options.popup.likes&&(likes='<div class="mfp-likes"><i class="qligg-icon-heart"></i>'+item.el.data("item").likes+"</div>"),(options.popup.likes||options.popup.comments)&&(info='<div class="mfp-info">'+likes+comments+date+"</div>"),item.src='<div class="mfp-figure '+options.popup.align+'">'+media+'<div class="mfp-close"></div><div class="mfp-bottom-bar"><div class="mfp-title">'+profile+counter+caption+info+"</div></div></div>"}},gallery:{enabled:!0}})})),$(".insta-gallery-feed").on("click",".insta-gallery-button.load",(function(e){e.preventDefault();var $item=$(e.delegateTarget),next_max_id;if(!$item.hasClass("loaded"))return!1;qligg_load_item_images($item,$(".insta-gallery-list .insta-gallery-item:last-child",$item).data("item").i)})),$(".insta-gallery-feed").each((function(index,item){var $item=$(item);if($item.hasClass("loaded"))return!1;qligg_load_item_images($item,0)})),-1!=navigator.appVersion.indexOf("MSIE 8.")&&(document.body.className+=" instagal-ie-8"),-1!=navigator.appVersion.indexOf("MSIE 9.")&&(document.body.className+=" instagal-ie-9")}(jQuery);
|
includes/api.php
DELETED
@@ -1,340 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if (!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
if (!class_exists('QLIGG_API')) {
|
7 |
-
|
8 |
-
class QLIGG_API
|
9 |
-
{
|
10 |
-
|
11 |
-
protected $instagram;
|
12 |
-
public $message;
|
13 |
-
public $instagram_url = 'https://www.instagram.com';
|
14 |
-
private $api_url = 'https://api.instagram.com';
|
15 |
-
|
16 |
-
public function get_create_account_link()
|
17 |
-
{
|
18 |
-
|
19 |
-
$admin_url = admin_url('admin.php?page-qligg_token');
|
20 |
-
$client_id = '6e628e63145746bcb684912009514665';
|
21 |
-
|
22 |
-
return "{$this->instagram_url}/oauth/authorize/?client_id={$client_id}&scope=basic&redirect_uri=https://instagram.quadlayers.com/index.php?return_uri={$admin_url}&response_type=token&state={$admin_url}&hl=en";
|
23 |
-
}
|
24 |
-
|
25 |
-
// API generate code generation url
|
26 |
-
// ---------------------------------------------------------------------------
|
27 |
-
/* public function get_access_code($client_id = null) {
|
28 |
-
|
29 |
-
$args = array(
|
30 |
-
'client_id' => $client_id,
|
31 |
-
'response_type' => 'code',
|
32 |
-
'scope' => 'public_content',
|
33 |
-
'redirect_uri' => urlencode(admin_url('admin.php?page=qligg_token&igigresponse=1'))
|
34 |
-
);
|
35 |
-
|
36 |
-
return add_query_arg($args, "{$this->api_url}/oauth/authorize/");
|
37 |
-
} */
|
38 |
-
|
39 |
-
// API call to get access token using authorization code
|
40 |
-
// ---------------------------------------------------------------------------
|
41 |
-
public function get_access_token($client_id, $client_secret, $redirect_uri, $code)
|
42 |
-
{
|
43 |
-
|
44 |
-
$args = array(
|
45 |
-
'body' => array(
|
46 |
-
'client_id' => $client_id,
|
47 |
-
'client_secret' => $client_secret,
|
48 |
-
'redirect_uri' => $redirect_uri,
|
49 |
-
'code' => $code,
|
50 |
-
'grant_type' => 'authorization_code',
|
51 |
-
'scope' => 'public_content'
|
52 |
-
)
|
53 |
-
);
|
54 |
-
|
55 |
-
$response = $this->validate_response(wp_remote_post("{$this->api_url}/oauth/access_token", $args));
|
56 |
-
|
57 |
-
if (isset($response['access_token'])) {
|
58 |
-
return $response['access_token'];
|
59 |
-
}
|
60 |
-
|
61 |
-
return false;
|
62 |
-
}
|
63 |
-
|
64 |
-
// API call to get user profile information using access token
|
65 |
-
// ---------------------------------------------------------------------------
|
66 |
-
public function get_user_profile($access_token)
|
67 |
-
{
|
68 |
-
|
69 |
-
$args = array(
|
70 |
-
'access_token' => $access_token
|
71 |
-
);
|
72 |
-
|
73 |
-
$url = "{$this->api_url}/v1/users/self";
|
74 |
-
|
75 |
-
$response = $this->remote_get($url, $args);
|
76 |
-
|
77 |
-
if (empty($response)) {
|
78 |
-
return false;
|
79 |
-
}
|
80 |
-
|
81 |
-
if (isset($response['meta']['code']) && ($response['meta']['code'] != 200) && isset($response['meta']['error_message'])) {
|
82 |
-
$this->message = $response['meta']['error_message'];
|
83 |
-
return false;
|
84 |
-
}
|
85 |
-
|
86 |
-
return isset($response['data']) ? $response['data'] : false;
|
87 |
-
}
|
88 |
-
|
89 |
-
// API call to check if access token is valid
|
90 |
-
// ---------------------------------------------------------------------------
|
91 |
-
public function validate_token($access_token)
|
92 |
-
{
|
93 |
-
|
94 |
-
$args = array(
|
95 |
-
'access_token' => $access_token
|
96 |
-
);
|
97 |
-
|
98 |
-
$url = "{$this->api_url}/v1/users/self";
|
99 |
-
|
100 |
-
$response = $this->remote_get($url, $args);
|
101 |
-
|
102 |
-
if (isset($response['meta']['code']) && $response['meta']['code'] == 200) {
|
103 |
-
return true;
|
104 |
-
}
|
105 |
-
|
106 |
-
if (isset($response['meta']['error_message'])) {
|
107 |
-
$this->message = $response['meta']['error_message'];
|
108 |
-
}
|
109 |
-
|
110 |
-
return false;
|
111 |
-
}
|
112 |
-
|
113 |
-
// API call to get user feed using access token
|
114 |
-
// ---------------------------------------------------------------------------
|
115 |
-
|
116 |
-
function setup_user_item($data, $next_max_id = null)
|
117 |
-
{
|
118 |
-
|
119 |
-
static $load = false;
|
120 |
-
static $i = 1;
|
121 |
-
|
122 |
-
if (!$next_max_id) {
|
123 |
-
$load = true;
|
124 |
-
}
|
125 |
-
|
126 |
-
$instagram_items = array();
|
127 |
-
|
128 |
-
if (is_array($data) && !empty($data)) {
|
129 |
-
|
130 |
-
foreach ($data as $item) {
|
131 |
-
|
132 |
-
if ($load) {
|
133 |
-
|
134 |
-
preg_match_all('/(?<!\S)#([0-9a-zA-Z]+)/', @$item['caption']['text'], $hashtags);
|
135 |
-
|
136 |
-
$instagram_items[] = array(
|
137 |
-
'i' => $i,
|
138 |
-
'id' => str_replace("_{$item['user']['id']}", '', $item['id']),
|
139 |
-
'images' => array(
|
140 |
-
'standard' => @$item['images']['standard_resolution']['url'],
|
141 |
-
'medium' => @$item['images']['low_resolution']['url'],
|
142 |
-
'small' => @$item['images']['thumbnail']['url'],
|
143 |
-
),
|
144 |
-
'videos' => array(
|
145 |
-
'standard' => @$item['videos']['standard_resolution']['url'],
|
146 |
-
'medium' => @$item['videos']['low_resolution']['url'],
|
147 |
-
'small' => @$item['videos']['thumbnail']['url'],
|
148 |
-
),
|
149 |
-
'likes' => @$item['likes']['count'],
|
150 |
-
'comments' => @$item['comments']['count'],
|
151 |
-
'caption' => preg_replace('/(?<!\S)#([0-9a-zA-Z]+)/', "<a href=\"{$this->instagram_url}/explore/tags/$1\">#$1</a>", htmlspecialchars(@$item['caption']['text'])),
|
152 |
-
'hashtags' => @$hashtags[1], // issue with uft 8 encode breakes json_encode
|
153 |
-
'link' => @$item['link'],
|
154 |
-
'type' => @$item['type'],
|
155 |
-
'user_id' => @$item['user']['id'],
|
156 |
-
'date' => date_i18n('j F, Y', @$item['created_time'])
|
157 |
-
);
|
158 |
-
}
|
159 |
-
if ($next_max_id && ($next_max_id == $i)) {
|
160 |
-
$i = $next_max_id;
|
161 |
-
$load = true;
|
162 |
-
}
|
163 |
-
$i++;
|
164 |
-
}
|
165 |
-
}
|
166 |
-
|
167 |
-
return $instagram_items;
|
168 |
-
}
|
169 |
-
|
170 |
-
public function get_user_items($access_token, $max_id = null)
|
171 |
-
{
|
172 |
-
|
173 |
-
$args = array(
|
174 |
-
'access_token' => $access_token,
|
175 |
-
'max_id' => $max_id,
|
176 |
-
'count' => 33
|
177 |
-
);
|
178 |
-
|
179 |
-
$url = "{$this->api_url}/v1/users/self/media/recent/";
|
180 |
-
|
181 |
-
$response = $this->remote_get($url, $args);
|
182 |
-
|
183 |
-
if (empty($response)) {
|
184 |
-
return false;
|
185 |
-
}
|
186 |
-
|
187 |
-
if (isset($response['meta']['code']) && ($response['meta']['code'] != 200) && isset($response['meta']['error_message'])) {
|
188 |
-
$this->message = $response['meta']['error_message'];
|
189 |
-
return false;
|
190 |
-
}
|
191 |
-
|
192 |
-
if (!isset($response['data'])) {
|
193 |
-
return false;
|
194 |
-
}
|
195 |
-
|
196 |
-
return $response;
|
197 |
-
}
|
198 |
-
|
199 |
-
// Tag name and return items list array
|
200 |
-
// -------------------------------------------------------------------------
|
201 |
-
|
202 |
-
function setup_tag_item($data, $next_max_id = null)
|
203 |
-
{
|
204 |
-
|
205 |
-
static $load = false;
|
206 |
-
static $i = 1;
|
207 |
-
|
208 |
-
if (!$next_max_id) {
|
209 |
-
$load = true;
|
210 |
-
}
|
211 |
-
|
212 |
-
$instagram_items = array();
|
213 |
-
|
214 |
-
if (is_array($data) && !empty($data)) {
|
215 |
-
|
216 |
-
foreach ($data as $res) {
|
217 |
-
|
218 |
-
if (!isset($res['node']['display_url'])) {
|
219 |
-
continue;
|
220 |
-
}
|
221 |
-
|
222 |
-
//preg_match_all("/#(\\w+)/", @$res['node']['edge_media_to_caption']['edges'][0]['node']['text'], $hashtags);
|
223 |
-
|
224 |
-
if ($load) {
|
225 |
-
$instagram_items[] = array(
|
226 |
-
'i' => $i,
|
227 |
-
'id' => $res['node']['id'],
|
228 |
-
'images' => array(
|
229 |
-
'standard' => $res['node']['display_url'],
|
230 |
-
'medium' => $res['node']['thumbnail_src'],
|
231 |
-
'small' => $res['node']['thumbnail_resources'][0]['src'],
|
232 |
-
),
|
233 |
-
'likes' => $res['node']['edge_liked_by']['count'],
|
234 |
-
'comments' => $res['node']['edge_media_to_comment']['count'],
|
235 |
-
'caption' => preg_replace('/(?<!\S)#([0-9a-zA-Z]+)/', "<a href=\"{$this->instagram_url}/explore/tags/$1\">#$1</a>", htmlspecialchars(@$res['node']['edge_media_to_caption']['edges'][0]['node']['text'])),
|
236 |
-
//'hashtags' => @$hashtags[1], // issue with uft 8 encode breakes json_encode
|
237 |
-
'link' => "{$this->instagram_url}/p/{$res['node']['shortcode']}/",
|
238 |
-
'type' => 'image', //@$types[$res['node']['__typename']],
|
239 |
-
'user_id' => $res['node']['owner']['id'],
|
240 |
-
'date' => date_i18n('j F, Y', strtotime($res['node']['taken_at_timestamp']))
|
241 |
-
);
|
242 |
-
}
|
243 |
-
if ($next_max_id && ($next_max_id == $i)) {
|
244 |
-
$i = $next_max_id;
|
245 |
-
$load = true;
|
246 |
-
}
|
247 |
-
$i++;
|
248 |
-
}
|
249 |
-
}
|
250 |
-
|
251 |
-
return $instagram_items;
|
252 |
-
}
|
253 |
-
|
254 |
-
public function get_tag_items($tag = null, $max_id = null)
|
255 |
-
{
|
256 |
-
|
257 |
-
if ($tag) {
|
258 |
-
|
259 |
-
$tag = urlencode((string) $tag);
|
260 |
-
|
261 |
-
$args = array(
|
262 |
-
'__a' => 1,
|
263 |
-
'max_id' => "{$max_id}="
|
264 |
-
);
|
265 |
-
|
266 |
-
$response = $this->remote_get("{$this->instagram_url}/explore/tags/{$tag}/", $args);
|
267 |
-
|
268 |
-
// API updated on Jan 03 17
|
269 |
-
// ---------------------------------------------------------------------
|
270 |
-
|
271 |
-
if (!isset($response['graphql']['hashtag']['edge_hashtag_to_media']['edges'])) {
|
272 |
-
return false;
|
273 |
-
}
|
274 |
-
|
275 |
-
return $response;
|
276 |
-
}
|
277 |
-
|
278 |
-
$this->message = esc_html__('Please provide a valid #tag', 'insta-gallery');
|
279 |
-
}
|
280 |
-
|
281 |
-
function validate_response($json = null)
|
282 |
-
{
|
283 |
-
|
284 |
-
if (!($response = json_decode(wp_remote_retrieve_body($json), true)) || 200 !== wp_remote_retrieve_response_code($json)) {
|
285 |
-
|
286 |
-
if (isset($response['meta']['error_message'])) {
|
287 |
-
$this->message = $response['meta']['error_message'];
|
288 |
-
return array(
|
289 |
-
'error' => 1,
|
290 |
-
'message' => $this->message
|
291 |
-
);
|
292 |
-
}
|
293 |
-
|
294 |
-
if (isset($response['error_message'])) {
|
295 |
-
$this->message = $response['error_message'];
|
296 |
-
return array(
|
297 |
-
'error' => 1,
|
298 |
-
'message' => $this->message
|
299 |
-
);
|
300 |
-
}
|
301 |
-
|
302 |
-
if (is_wp_error($json)) {
|
303 |
-
$response = array(
|
304 |
-
'error' => 1,
|
305 |
-
'message' => $json->get_error_message()
|
306 |
-
);
|
307 |
-
} else {
|
308 |
-
$response = array(
|
309 |
-
'error' => 1,
|
310 |
-
'message' => esc_html__('Unknow error occurred, please try again', 'insta-gallery')
|
311 |
-
);
|
312 |
-
}
|
313 |
-
}
|
314 |
-
|
315 |
-
return $response;
|
316 |
-
}
|
317 |
-
|
318 |
-
public function remote_get($url = null, $args = array())
|
319 |
-
{
|
320 |
-
|
321 |
-
$url = add_query_arg($args, trailingslashit($url));
|
322 |
-
|
323 |
-
$response = $this->validate_response(wp_remote_get($url, array('timeout' => 29)));
|
324 |
-
|
325 |
-
return $response;
|
326 |
-
}
|
327 |
-
|
328 |
-
// Return message
|
329 |
-
// ---------------------------------------------------------------------------
|
330 |
-
public function get_message()
|
331 |
-
{
|
332 |
-
return $this->message;
|
333 |
-
}
|
334 |
-
|
335 |
-
public function set_message($message = '')
|
336 |
-
{
|
337 |
-
$this->message = $message;
|
338 |
-
}
|
339 |
-
}
|
340 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/api/api.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
include_once(QLIGG_PLUGIN_DIR . 'includes/api/apiBusiness.php');
|
7 |
+
|
8 |
+
include_once(QLIGG_PLUGIN_DIR . 'includes/models/Account.php');
|
9 |
+
include_once(QLIGG_PLUGIN_DIR . 'includes/models/Feed.php');
|
10 |
+
|
11 |
+
abstract class QLIGG_API
|
12 |
+
{
|
13 |
+
protected static $_instance;
|
14 |
+
public $messages = array();
|
15 |
+
|
16 |
+
function setupMediaItems($data, $last_id = null)
|
17 |
+
{
|
18 |
+
global $qliggAPI;
|
19 |
+
|
20 |
+
return $qliggAPI->FEED->setupMediaItems($data, $last_id = null);
|
21 |
+
}
|
22 |
+
|
23 |
+
function validateResponse($json = null)
|
24 |
+
{
|
25 |
+
global $qliggAPI;
|
26 |
+
|
27 |
+
if (!($response = json_decode(wp_remote_retrieve_body($json), true)) || 200 !== wp_remote_retrieve_response_code($json)) {
|
28 |
+
|
29 |
+
if (is_wp_error($json)) {
|
30 |
+
$response = array(
|
31 |
+
'error' => 1,
|
32 |
+
'message' => $json->get_error_message()
|
33 |
+
);
|
34 |
+
} elseif (isset($response['error']['message'])) {
|
35 |
+
$response = array(
|
36 |
+
'error' => 1,
|
37 |
+
'message' => $response['error']['message']
|
38 |
+
);
|
39 |
+
} else {
|
40 |
+
$response = array(
|
41 |
+
'error' => 1,
|
42 |
+
'message' => esc_html__('Unknow error occurred, please try again', 'insta-gallery')
|
43 |
+
);
|
44 |
+
}
|
45 |
+
|
46 |
+
$qliggAPI->FEED->setMessage($response['message']);
|
47 |
+
}
|
48 |
+
|
49 |
+
return $response;
|
50 |
+
}
|
51 |
+
|
52 |
+
public function remoteGet($url = null, $args = array())
|
53 |
+
{
|
54 |
+
|
55 |
+
$url = add_query_arg($args, trailingslashit($url));
|
56 |
+
|
57 |
+
$response = $this->validateResponse(wp_remote_get($url, array('timeout' => 29)));
|
58 |
+
|
59 |
+
return $response;
|
60 |
+
}
|
61 |
+
}
|
includes/api/apiBASIC.php
ADDED
@@ -0,0 +1,346 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
class QLIGG_API_Basic
|
7 |
+
{
|
8 |
+
|
9 |
+
protected static $_instance;
|
10 |
+
protected $instagram;
|
11 |
+
public $message;
|
12 |
+
public $instagram_url = 'https://www.instagram.com';
|
13 |
+
private $api_url = 'https://api.instagram.com';
|
14 |
+
|
15 |
+
public static function instance()
|
16 |
+
{
|
17 |
+
if (is_null(self::$_instance)) {
|
18 |
+
self::$_instance = new self();
|
19 |
+
}
|
20 |
+
return self::$_instance;
|
21 |
+
}
|
22 |
+
|
23 |
+
public function get_create_account_link()
|
24 |
+
{
|
25 |
+
|
26 |
+
$admin_url = admin_url('admin.php?page-qligg_token');
|
27 |
+
$client_id = '6e628e63145746bcb684912009514665';
|
28 |
+
|
29 |
+
return "{$this->instagram_url}/oauth/authorize/?client_id={$client_id}&scope=basic&redirect_uri=https://instagram.quadlayers.com/index.php?return_uri={$admin_url}&response_type=token&state={$admin_url}&hl=en";
|
30 |
+
}
|
31 |
+
|
32 |
+
// API generate code generation url
|
33 |
+
// ---------------------------------------------------------------------------
|
34 |
+
/* public function get_access_code($client_id = null) {
|
35 |
+
|
36 |
+
$args = array(
|
37 |
+
'client_id' => $client_id,
|
38 |
+
'response_type' => 'code',
|
39 |
+
'scope' => 'public_content',
|
40 |
+
'redirect_uri' => urlencode(admin_url('admin.php?page=qligg_token&igigresponse=1'))
|
41 |
+
);
|
42 |
+
|
43 |
+
return add_query_arg($args, "{$this->api_url}/oauth/authorize/");
|
44 |
+
} */
|
45 |
+
|
46 |
+
// API call to get access token using authorization code
|
47 |
+
// ---------------------------------------------------------------------------
|
48 |
+
public function get_access_token($client_id, $client_secret, $redirect_uri, $code)
|
49 |
+
{
|
50 |
+
|
51 |
+
$args = array(
|
52 |
+
'body' => array(
|
53 |
+
'client_id' => $client_id,
|
54 |
+
'client_secret' => $client_secret,
|
55 |
+
'redirect_uri' => $redirect_uri,
|
56 |
+
'code' => $code,
|
57 |
+
'grant_type' => 'authorization_code',
|
58 |
+
'scope' => 'public_content'
|
59 |
+
)
|
60 |
+
);
|
61 |
+
|
62 |
+
$response = $this->validate_response(wp_remote_post("{$this->api_url}/oauth/access_token", $args));
|
63 |
+
|
64 |
+
if (isset($response['access_token'])) {
|
65 |
+
return $response['access_token'];
|
66 |
+
}
|
67 |
+
|
68 |
+
return false;
|
69 |
+
}
|
70 |
+
|
71 |
+
// API call to get user profile information using access token
|
72 |
+
// ---------------------------------------------------------------------------
|
73 |
+
public function get_user_profile($access_token)
|
74 |
+
{
|
75 |
+
|
76 |
+
$args = array(
|
77 |
+
'access_token' => $access_token
|
78 |
+
);
|
79 |
+
|
80 |
+
$url = "{$this->api_url}/v1/users/self";
|
81 |
+
|
82 |
+
$response = $this->remote_get($url, $args);
|
83 |
+
|
84 |
+
if (empty($response)) {
|
85 |
+
return false;
|
86 |
+
}
|
87 |
+
|
88 |
+
if (isset($response['meta']['code']) && ($response['meta']['code'] != 200) && isset($response['meta']['error_message'])) {
|
89 |
+
$this->message = $response['meta']['error_message'];
|
90 |
+
return false;
|
91 |
+
}
|
92 |
+
|
93 |
+
return isset($response['data']) ? $response['data'] : false;
|
94 |
+
}
|
95 |
+
|
96 |
+
// API call to check if access token is valid
|
97 |
+
// ---------------------------------------------------------------------------
|
98 |
+
public function validate_token($access_token)
|
99 |
+
{
|
100 |
+
|
101 |
+
$args = array(
|
102 |
+
'access_token' => $access_token
|
103 |
+
);
|
104 |
+
|
105 |
+
$url = "{$this->api_url}/v1/users/self";
|
106 |
+
|
107 |
+
$response = $this->remote_get($url, $args);
|
108 |
+
|
109 |
+
if (isset($response['meta']['code']) && $response['meta']['code'] == 200) {
|
110 |
+
return true;
|
111 |
+
}
|
112 |
+
|
113 |
+
if (isset($response['meta']['error_message'])) {
|
114 |
+
$this->message = $response['meta']['error_message'];
|
115 |
+
}
|
116 |
+
|
117 |
+
return false;
|
118 |
+
}
|
119 |
+
|
120 |
+
// API call to get user feed using access token
|
121 |
+
// ---------------------------------------------------------------------------
|
122 |
+
|
123 |
+
function setup_user_item($data, $next_max_id = null)
|
124 |
+
{
|
125 |
+
|
126 |
+
static $load = false;
|
127 |
+
static $i = 1;
|
128 |
+
|
129 |
+
if (!$next_max_id) {
|
130 |
+
$load = true;
|
131 |
+
}
|
132 |
+
|
133 |
+
$instagram_items = array();
|
134 |
+
|
135 |
+
if (is_array($data) && !empty($data)) {
|
136 |
+
|
137 |
+
foreach ($data as $item) {
|
138 |
+
|
139 |
+
if ($load) {
|
140 |
+
|
141 |
+
preg_match_all('/(?<!\S)#([0-9a-zA-Z]+)/', @$item['caption']['text'], $hashtags);
|
142 |
+
|
143 |
+
$instagram_items[] = array(
|
144 |
+
'i' => $i,
|
145 |
+
'id' => str_replace("_{$item['user']['id']}", '', $item['id']),
|
146 |
+
'images' => array(
|
147 |
+
'standard' => @$item['images']['standard_resolution']['url'],
|
148 |
+
'medium' => @$item['images']['low_resolution']['url'],
|
149 |
+
'small' => @$item['images']['thumbnail']['url'],
|
150 |
+
),
|
151 |
+
'videos' => array(
|
152 |
+
'standard' => @$item['videos']['standard_resolution']['url'],
|
153 |
+
'medium' => @$item['videos']['low_resolution']['url'],
|
154 |
+
'small' => @$item['videos']['thumbnail']['url'],
|
155 |
+
),
|
156 |
+
'likes' => @$item['likes']['count'],
|
157 |
+
'comments' => @$item['comments']['count'],
|
158 |
+
'caption' => preg_replace('/(?<!\S)#([0-9a-zA-Z]+)/', "<a href=\"{$this->instagram_url}/explore/tags/$1\">#$1</a>", htmlspecialchars(@$item['caption']['text'])),
|
159 |
+
'hashtags' => @$hashtags[1], // issue with uft 8 encode breakes json_encode
|
160 |
+
'link' => @$item['link'],
|
161 |
+
'type' => @$item['type'],
|
162 |
+
'user_id' => @$item['user']['id'],
|
163 |
+
'date' => date_i18n('j F, Y', @$item['created_time'])
|
164 |
+
);
|
165 |
+
}
|
166 |
+
if ($next_max_id && ($next_max_id == $i)) {
|
167 |
+
$i = $next_max_id;
|
168 |
+
$load = true;
|
169 |
+
}
|
170 |
+
$i++;
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
return $instagram_items;
|
175 |
+
}
|
176 |
+
|
177 |
+
public function get_user_items($access_token, $max_id = null)
|
178 |
+
{
|
179 |
+
|
180 |
+
$args = array(
|
181 |
+
'access_token' => $access_token,
|
182 |
+
'max_id' => $max_id,
|
183 |
+
'count' => 33
|
184 |
+
);
|
185 |
+
|
186 |
+
$url = "{$this->api_url}/v1/users/self/media/recent/";
|
187 |
+
|
188 |
+
$response = $this->remote_get($url, $args);
|
189 |
+
|
190 |
+
if (empty($response)) {
|
191 |
+
return false;
|
192 |
+
}
|
193 |
+
|
194 |
+
if (isset($response['meta']['code']) && ($response['meta']['code'] != 200) && isset($response['meta']['error_message'])) {
|
195 |
+
$this->message = $response['meta']['error_message'];
|
196 |
+
return false;
|
197 |
+
}
|
198 |
+
|
199 |
+
if (!isset($response['data'])) {
|
200 |
+
return false;
|
201 |
+
}
|
202 |
+
|
203 |
+
return $response;
|
204 |
+
}
|
205 |
+
|
206 |
+
// Tag name and return items list array
|
207 |
+
// -------------------------------------------------------------------------
|
208 |
+
|
209 |
+
function setup_tag_item($data, $next_max_id = null)
|
210 |
+
{
|
211 |
+
|
212 |
+
static $load = false;
|
213 |
+
static $i = 1;
|
214 |
+
|
215 |
+
if (!$next_max_id) {
|
216 |
+
$load = true;
|
217 |
+
}
|
218 |
+
|
219 |
+
$instagram_items = array();
|
220 |
+
|
221 |
+
if (is_array($data) && !empty($data)) {
|
222 |
+
|
223 |
+
foreach ($data as $res) {
|
224 |
+
|
225 |
+
if (!isset($res['node']['display_url'])) {
|
226 |
+
continue;
|
227 |
+
}
|
228 |
+
|
229 |
+
//preg_match_all("/#(\\w+)/", @$res['node']['edge_media_to_caption']['edges'][0]['node']['text'], $hashtags);
|
230 |
+
|
231 |
+
if ($load) {
|
232 |
+
$instagram_items[] = array(
|
233 |
+
'i' => $i,
|
234 |
+
'id' => $res['node']['id'],
|
235 |
+
'images' => array(
|
236 |
+
'standard' => $res['node']['display_url'],
|
237 |
+
'medium' => $res['node']['thumbnail_src'],
|
238 |
+
'small' => $res['node']['thumbnail_resources'][0]['src'],
|
239 |
+
),
|
240 |
+
'likes' => $res['node']['edge_liked_by']['count'],
|
241 |
+
'comments' => $res['node']['edge_media_to_comment']['count'],
|
242 |
+
'caption' => preg_replace('/(?<!\S)#([0-9a-zA-Z]+)/', "<a href=\"{$this->instagram_url}/explore/tags/$1\">#$1</a>", htmlspecialchars(@$res['node']['edge_media_to_caption']['edges'][0]['node']['text'])),
|
243 |
+
//'hashtags' => @$hashtags[1], // issue with uft 8 encode breakes json_encode
|
244 |
+
'link' => "{$this->instagram_url}/p/{$res['node']['shortcode']}/",
|
245 |
+
'type' => 'image', //@$types[$res['node']['__typename']],
|
246 |
+
'user_id' => $res['node']['owner']['id'],
|
247 |
+
'date' => date_i18n('j F, Y', strtotime($res['node']['taken_at_timestamp']))
|
248 |
+
);
|
249 |
+
}
|
250 |
+
if ($next_max_id && ($next_max_id == $i)) {
|
251 |
+
$i = $next_max_id;
|
252 |
+
$load = true;
|
253 |
+
}
|
254 |
+
$i++;
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
return $instagram_items;
|
259 |
+
}
|
260 |
+
|
261 |
+
public function get_tag_items($tag = null, $max_id = null)
|
262 |
+
{
|
263 |
+
|
264 |
+
if ($tag) {
|
265 |
+
|
266 |
+
$tag = urlencode((string) $tag);
|
267 |
+
|
268 |
+
$args = array(
|
269 |
+
'__a' => 1,
|
270 |
+
'max_id' => "{$max_id}="
|
271 |
+
);
|
272 |
+
|
273 |
+
$response = $this->remote_get("{$this->instagram_url}/explore/tags/{$tag}/", $args);
|
274 |
+
|
275 |
+
// API updated on Jan 03 17
|
276 |
+
// ---------------------------------------------------------------------
|
277 |
+
|
278 |
+
if (!isset($response['graphql']['hashtag']['edge_hashtag_to_media']['edges'])) {
|
279 |
+
return false;
|
280 |
+
}
|
281 |
+
|
282 |
+
return $response;
|
283 |
+
}
|
284 |
+
|
285 |
+
$this->message = esc_html__('Please provide a valid #tag', 'insta-gallery');
|
286 |
+
}
|
287 |
+
|
288 |
+
function validate_response($json = null)
|
289 |
+
{
|
290 |
+
|
291 |
+
if (!($response = json_decode(wp_remote_retrieve_body($json), true)) || 200 !== wp_remote_retrieve_response_code($json)) {
|
292 |
+
|
293 |
+
if (isset($response['meta']['error_message'])) {
|
294 |
+
$this->message = $response['meta']['error_message'];
|
295 |
+
return array(
|
296 |
+
'error' => 1,
|
297 |
+
'message' => $this->message
|
298 |
+
);
|
299 |
+
}
|
300 |
+
|
301 |
+
if (isset($response['error_message'])) {
|
302 |
+
$this->message = $response['error_message'];
|
303 |
+
return array(
|
304 |
+
'error' => 1,
|
305 |
+
'message' => $this->message
|
306 |
+
);
|
307 |
+
}
|
308 |
+
|
309 |
+
if (is_wp_error($json)) {
|
310 |
+
$response = array(
|
311 |
+
'error' => 1,
|
312 |
+
'message' => $json->get_error_message()
|
313 |
+
);
|
314 |
+
} else {
|
315 |
+
$response = array(
|
316 |
+
'error' => 1,
|
317 |
+
'message' => esc_html__('Unknow error occurred, please try again', 'insta-gallery')
|
318 |
+
);
|
319 |
+
}
|
320 |
+
}
|
321 |
+
|
322 |
+
return $response;
|
323 |
+
}
|
324 |
+
|
325 |
+
public function remote_get($url = null, $args = array())
|
326 |
+
{
|
327 |
+
|
328 |
+
$url = add_query_arg($args, trailingslashit($url));
|
329 |
+
|
330 |
+
$response = $this->validate_response(wp_remote_get($url, array('timeout' => 29)));
|
331 |
+
|
332 |
+
return $response;
|
333 |
+
}
|
334 |
+
|
335 |
+
// Return message
|
336 |
+
// ---------------------------------------------------------------------------
|
337 |
+
public function get_message()
|
338 |
+
{
|
339 |
+
return $this->message;
|
340 |
+
}
|
341 |
+
|
342 |
+
public function set_message($message = '')
|
343 |
+
{
|
344 |
+
$this->message = $message;
|
345 |
+
}
|
346 |
+
}
|
includes/api/apiBusiness.php
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
include_once(QLIGG_PLUGIN_DIR . 'includes/api/api.php');
|
7 |
+
|
8 |
+
class QLIGG_API_Business extends QLIGG_API
|
9 |
+
{
|
10 |
+
|
11 |
+
protected static $_instance;
|
12 |
+
public $client_id = '834353156975525';
|
13 |
+
public $graph_url = 'https://graph.facebook.com';
|
14 |
+
public $redirect_uri = 'https://socialfeed.quadlayers.com/facebook.php';
|
15 |
+
|
16 |
+
public static function instance()
|
17 |
+
{
|
18 |
+
if (is_null(self::$_instance)) {
|
19 |
+
self::$_instance = new self();
|
20 |
+
}
|
21 |
+
return self::$_instance;
|
22 |
+
}
|
23 |
+
|
24 |
+
function getAccessTokenLink()
|
25 |
+
{
|
26 |
+
|
27 |
+
$state = admin_url('admin.php');
|
28 |
+
$scope = 'instagram_basic,instagram_manage_insights,instagram_manage_comments,manage_pages,pages_read_engagement';
|
29 |
+
|
30 |
+
return "https://www.facebook.com/dialog/oauth?client_id={$this->client_id}&redirect_uri={$this->redirect_uri}&response_type=code&scope={$scope}&state={$state}";
|
31 |
+
}
|
32 |
+
|
33 |
+
function getUserProfile($account_id, $access_token)
|
34 |
+
{
|
35 |
+
$response = $this->remoteGet("https://graph.facebook.com/{$account_id}", array(
|
36 |
+
'fields' => 'id,username,website,biography,name,followers_count,media_count,profile_picture_url',
|
37 |
+
'access_token' => $access_token
|
38 |
+
));
|
39 |
+
|
40 |
+
return (array) $response;
|
41 |
+
}
|
42 |
+
|
43 |
+
function getUserMedia($account_id, $access_token, $after = null)
|
44 |
+
{
|
45 |
+
|
46 |
+
$limit = 50; //$num = min( $num, 200 );
|
47 |
+
|
48 |
+
$response = $this->remoteGet("{$this->graph_url}/{$account_id}/media", array(
|
49 |
+
'after' => $after,
|
50 |
+
'limit' => $limit,
|
51 |
+
'fields' => 'media_url,thumbnail_url,caption,id,media_type,timestamp,username,comments_count,like_count,permalink,children{media_url,id,media_type,timestamp,permalink,thumbnail_url}',
|
52 |
+
'access_token' => $access_token
|
53 |
+
));
|
54 |
+
|
55 |
+
return (array) $response;
|
56 |
+
}
|
57 |
+
|
58 |
+
function getTagId($account_id, $access_token, $hashtag = null)
|
59 |
+
{
|
60 |
+
|
61 |
+
$response = $this->remoteGet("{$this->graph_url}/ig_hashtag_search", array(
|
62 |
+
'user_id' => $account_id,
|
63 |
+
'q' => urlencode($hashtag),
|
64 |
+
'access_token' => $access_token
|
65 |
+
));
|
66 |
+
|
67 |
+
if (isset($response['data'][0]['id'])) {
|
68 |
+
return $response['data'][0]['id'];
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
function getTagMedia($account_id, $hashtag = null, $order_by = 'recent_media', $after = null)
|
73 |
+
{
|
74 |
+
|
75 |
+
global $qliggAPI;
|
76 |
+
|
77 |
+
if (!$hashtag) {
|
78 |
+
$qliggAPI->FEED->setMessage(esc_html__('Please update Instagram Tag in the feed settings.', 'insta-gallery'));
|
79 |
+
return;
|
80 |
+
}
|
81 |
+
|
82 |
+
if (!$account_id) {
|
83 |
+
$qliggAPI->FEED->setMessage(esc_html__('Please update Instagram Account in the feed settings.', 'insta-gallery'));
|
84 |
+
return;
|
85 |
+
}
|
86 |
+
|
87 |
+
$account_model = new QLIGG_Account();
|
88 |
+
|
89 |
+
$account = $account_model->get_account($account_id);
|
90 |
+
|
91 |
+
if (!isset($account['access_token'])) {
|
92 |
+
$qliggAPI->FEED->setMessage(esc_html__('Please update Instagram Access Token in the account and feed settings.', 'insta-gallery'));
|
93 |
+
return;
|
94 |
+
}
|
95 |
+
|
96 |
+
if (!isset($account['token_type']) || $account['token_type'] != 'BUSINESS') {
|
97 |
+
$qliggAPI->FEED->setMessage(esc_html__('Please use a business Instagram Access Token to display tags.', 'insta-gallery'));
|
98 |
+
return;
|
99 |
+
}
|
100 |
+
|
101 |
+
if (!$hashtag_id = $this->getTagId($account['id'], $account['access_token'], $hashtag)) {
|
102 |
+
$qliggAPI->FEED->setMessage(sprintf(esc_html__('Can\'t find the tag %s.', 'insta-gallery'), $hashtag));
|
103 |
+
return;
|
104 |
+
}
|
105 |
+
|
106 |
+
$limit = 50; //$num = min( $num, 200 );
|
107 |
+
$order_by = $order_by == 'top_media' ? 'top_media' : 'recent_media';
|
108 |
+
|
109 |
+
$response = $this->remoteGet("{$this->graph_url}/{$hashtag_id}/{$order_by}", array(
|
110 |
+
'after' => $after,
|
111 |
+
'user_id' => $account['id'],
|
112 |
+
'limit' => $limit,
|
113 |
+
'fields' => 'media_url,caption,id,media_type,comments_count,like_count,permalink,children{media_url,id,media_type,permalink}',
|
114 |
+
'access_token' => $account['access_token']
|
115 |
+
));
|
116 |
+
|
117 |
+
return (array) $response;
|
118 |
+
}
|
119 |
+
}
|
includes/api/apiFeed.php
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
include_once(QLIGG_PLUGIN_DIR . 'includes/models/Account.php');
|
7 |
+
include_once(QLIGG_PLUGIN_DIR . 'includes/models/Feed.php');
|
8 |
+
|
9 |
+
class QLIGG_API_Feed
|
10 |
+
{
|
11 |
+
protected static $_instance;
|
12 |
+
public $messages = array();
|
13 |
+
public $instagram_url = 'https://www.instagram.com';
|
14 |
+
|
15 |
+
public static function instance()
|
16 |
+
{
|
17 |
+
if (is_null(self::$_instance)) {
|
18 |
+
self::$_instance = new self();
|
19 |
+
}
|
20 |
+
return self::$_instance;
|
21 |
+
}
|
22 |
+
|
23 |
+
function setupMediaItems($data, $last_id = null)
|
24 |
+
{
|
25 |
+
|
26 |
+
static $load = false;
|
27 |
+
static $i = 1;
|
28 |
+
|
29 |
+
if (!$last_id) {
|
30 |
+
$load = true;
|
31 |
+
}
|
32 |
+
|
33 |
+
$instagram_items = array();
|
34 |
+
|
35 |
+
if (is_array($data) && !empty($data)) {
|
36 |
+
|
37 |
+
foreach ($data as $item) {
|
38 |
+
|
39 |
+
if ($load) {
|
40 |
+
|
41 |
+
preg_match_all('/(?<!\S)#([0-9a-zA-Z]+)/', @$item['caption'], $hashtags);
|
42 |
+
|
43 |
+
$media_url = ($item['media_type'] === 'CAROUSEL_ALBUM') ? @$item['children']['data'][0]['media_url'] : @$item['media_url'];
|
44 |
+
$date = isset($item['timestamp']) ? date_i18n('j F, Y', strtotime(trim(str_replace(array('T', '+', ' 0000'), ' ', $item['timestamp'])))) : false;
|
45 |
+
|
46 |
+
$test = $instagram_items[] = array(
|
47 |
+
'i' => $i,
|
48 |
+
'id' => $item['id'],
|
49 |
+
'type' => strtolower(str_replace('_ALBUM', '', $item['media_type'])),
|
50 |
+
'media' => $media_url,
|
51 |
+
'images' => array(
|
52 |
+
'standard' => "{$item['permalink']}media?size=l",
|
53 |
+
'medium' => "{$item['permalink']}media?size=m",
|
54 |
+
'small' => "{$item['permalink']}media?size=t",
|
55 |
+
),
|
56 |
+
'videos' => array(
|
57 |
+
'standard' => "{$item['permalink']}media?size=l",
|
58 |
+
'medium' => "{$item['permalink']}media?size=m",
|
59 |
+
'small' => "{$item['permalink']}media?size=t",
|
60 |
+
),
|
61 |
+
'likes' => isset($item['like_count']) ? $item['like_count'] : false,
|
62 |
+
'comments' => isset($item['comments_count']) ? $item['comments_count'] : false,
|
63 |
+
'caption' => preg_replace('/(?<!\S)#([0-9a-zA-Z]+)/', "<a href=\"{$this->instagram_url}/explore/tags/$1\">#$1</a>", htmlspecialchars(@$item['caption'])),
|
64 |
+
'hashtags' => @$hashtags[1], //array_map('utf8_encode', (array) @$hashtags[1]), // issue with uft 8 encode breakes json_encode
|
65 |
+
'link' => $item['permalink'],
|
66 |
+
'date' => $date
|
67 |
+
);
|
68 |
+
}
|
69 |
+
|
70 |
+
if ($last_id && ($last_id == $i)) {
|
71 |
+
$i = $last_id;
|
72 |
+
$load = true;
|
73 |
+
}
|
74 |
+
$i++;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
return $instagram_items;
|
79 |
+
}
|
80 |
+
|
81 |
+
// Return messages
|
82 |
+
// ---------------------------------------------------------------------------
|
83 |
+
public function getMessages()
|
84 |
+
{
|
85 |
+
return $this->messages;
|
86 |
+
}
|
87 |
+
|
88 |
+
public function setMessage($message = '')
|
89 |
+
{
|
90 |
+
$this->messages[] = $message;
|
91 |
+
}
|
92 |
+
}
|
includes/api/apiPersonal.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
include_once(QLIGG_PLUGIN_DIR . 'includes/api/api.php');
|
7 |
+
|
8 |
+
class QLIGG_API_Personal extends QLIGG_API
|
9 |
+
{
|
10 |
+
|
11 |
+
protected static $_instance;
|
12 |
+
public $client_id = '504270170253170';
|
13 |
+
public $graph_url = 'https://graph.instagram.com';
|
14 |
+
public $redirect_uri = 'https://socialfeed.quadlayers.com/instagram.php';
|
15 |
+
|
16 |
+
public static function instance()
|
17 |
+
{
|
18 |
+
if (is_null(self::$_instance)) {
|
19 |
+
self::$_instance = new self();
|
20 |
+
}
|
21 |
+
return self::$_instance;
|
22 |
+
}
|
23 |
+
|
24 |
+
function getAccessTokenLink()
|
25 |
+
{
|
26 |
+
|
27 |
+
$state = admin_url('admin.php');
|
28 |
+
$scope = 'user_profile,user_media';
|
29 |
+
|
30 |
+
return "https://www.instagram.com/oauth/authorize?app_id={$this->client_id}&redirect_uri={$this->redirect_uri}&response_type=code&scope={$scope}&state={$state}";
|
31 |
+
}
|
32 |
+
|
33 |
+
function getUserProfile($access_token)
|
34 |
+
{
|
35 |
+
|
36 |
+
$response = $this->remoteGet("{$this->graph_url}/me", array(
|
37 |
+
'fields' => 'id,media_count,username,account_type',
|
38 |
+
'access_token' => $access_token
|
39 |
+
));
|
40 |
+
|
41 |
+
return (array) $response;
|
42 |
+
}
|
43 |
+
|
44 |
+
function getUserMedia($access_token, $after = null)
|
45 |
+
{
|
46 |
+
|
47 |
+
$limit = 50; //$num = min( $num, 200 );
|
48 |
+
|
49 |
+
$response = $this->remoteGet("{$this->graph_url}/me/media", array(
|
50 |
+
'after' => $after,
|
51 |
+
'limit' => $limit,
|
52 |
+
'fields' => 'media_url,thumbnail_url,caption,id,media_type,timestamp,username,comments_count,like_count,permalink,children{media_url,id,media_type,timestamp,permalink,thumbnail_url}',
|
53 |
+
'access_token' => $access_token
|
54 |
+
));
|
55 |
+
|
56 |
+
return (array) $response;
|
57 |
+
}
|
58 |
+
}
|
includes/apiFacebook.php
DELETED
@@ -1,218 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if (!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
include_once(QLIGG_PLUGIN_DIR . 'includes/models/Account.php');
|
7 |
-
|
8 |
-
class QLIGG_API_Facebook
|
9 |
-
{
|
10 |
-
public $message;
|
11 |
-
public $facebook_id = '834353156975525';
|
12 |
-
public $facebook_url = 'https://www.facebook.com';
|
13 |
-
public $facebook_graph_url = 'https://graph.facebook.com';
|
14 |
-
public $facebook_redirect_uri = 'https://socialfeed.quadlayers.com/facebook.php';
|
15 |
-
public $instagram_url = 'https://www.instagram.com';
|
16 |
-
|
17 |
-
function getAccessTokenLink()
|
18 |
-
{
|
19 |
-
|
20 |
-
$state = admin_url('admin.php');
|
21 |
-
$scope = 'instagram_basic,instagram_manage_insights,instagram_manage_comments,manage_pages,pages_read_engagement';
|
22 |
-
|
23 |
-
|
24 |
-
return "{$this->facebook_url}/dialog/oauth?client_id={$this->facebook_id}&redirect_uri={$this->facebook_redirect_uri}&response_type=code&scope={$scope}&state={$state}";
|
25 |
-
}
|
26 |
-
|
27 |
-
function getUserProfile($account_id, $access_token)
|
28 |
-
{
|
29 |
-
$response = $this->remoteGet("https://graph.facebook.com/{$account_id}", array(
|
30 |
-
'fields' => 'id,username,website,biography,name,followers_count,media_count,profile_picture_url',
|
31 |
-
'access_token' => $access_token
|
32 |
-
));
|
33 |
-
|
34 |
-
return (array) $response;
|
35 |
-
}
|
36 |
-
|
37 |
-
function getUserMedia($account_id, $access_token, $after = null)
|
38 |
-
{
|
39 |
-
|
40 |
-
$limit = 30; //$num = min( $num, 200 );
|
41 |
-
|
42 |
-
$response = $this->remoteGet("{$this->facebook_graph_url}/{$account_id}/media", array(
|
43 |
-
'after' => $after,
|
44 |
-
'limit' => $limit,
|
45 |
-
'fields' => 'media_url,thumbnail_url,caption,id,media_type,timestamp,username,comments_count,like_count,permalink,children{media_url,id,media_type,timestamp,permalink,thumbnail_url}',
|
46 |
-
'access_token' => $access_token
|
47 |
-
));
|
48 |
-
|
49 |
-
return (array) $response;
|
50 |
-
}
|
51 |
-
|
52 |
-
function setupMediaItems($data, $last_id = null)
|
53 |
-
{
|
54 |
-
|
55 |
-
static $load = false;
|
56 |
-
static $i = 1;
|
57 |
-
|
58 |
-
if (!$last_id) {
|
59 |
-
$load = true;
|
60 |
-
}
|
61 |
-
|
62 |
-
$instagram_items = array();
|
63 |
-
|
64 |
-
if (is_array($data) && !empty($data)) {
|
65 |
-
|
66 |
-
foreach ($data as $item) {
|
67 |
-
|
68 |
-
if ($load) {
|
69 |
-
|
70 |
-
preg_match_all('/(?<!\S)#([0-9a-zA-Z]+)/', @$item['caption'], $hashtags);
|
71 |
-
|
72 |
-
$media_url = ($item['media_type'] === 'CAROUSEL_ALBUM') ? @$item['children']['data'][0]['media_url'] : @$item['media_url'];
|
73 |
-
$date = isset($item['timestamp']) ? date_i18n('j F, Y', strtotime(trim(str_replace(array('T', '+', ' 0000'), ' ', $item['timestamp'])))) : false;
|
74 |
-
|
75 |
-
$test = $instagram_items[] = array(
|
76 |
-
'i' => $i,
|
77 |
-
'id' => $item['id'],
|
78 |
-
'type' => strtolower(str_replace('_ALBUM', '', $item['media_type'])),
|
79 |
-
'media' => $media_url,
|
80 |
-
'images' => array(
|
81 |
-
'standard' => "{$item['permalink']}media?size=l",
|
82 |
-
'medium' => "{$item['permalink']}media?size=m",
|
83 |
-
'small' => "{$item['permalink']}media?size=t",
|
84 |
-
),
|
85 |
-
'videos' => array(
|
86 |
-
'standard' => "{$item['permalink']}media?size=l",
|
87 |
-
'medium' => "{$item['permalink']}media?size=m",
|
88 |
-
'small' => "{$item['permalink']}media?size=t",
|
89 |
-
),
|
90 |
-
'likes' => isset($item['like_count']) ? $item['like_count'] : false,
|
91 |
-
'comments' => isset($item['comments_count']) ? $item['comments_count'] : false,
|
92 |
-
'caption' => preg_replace('/(?<!\S)#([0-9a-zA-Z]+)/', "<a href=\"{$this->instagram_url}/explore/tags/$1\">#$1</a>", htmlspecialchars(@$item['caption'])),
|
93 |
-
'hashtags' => @$hashtags[1], //array_map('utf8_encode', (array) @$hashtags[1]), // issue with uft 8 encode breakes json_encode
|
94 |
-
'link' => $item['permalink'],
|
95 |
-
'date' => $date
|
96 |
-
);
|
97 |
-
}
|
98 |
-
|
99 |
-
if ($last_id && ($last_id == $i)) {
|
100 |
-
$i = $last_id;
|
101 |
-
$load = true;
|
102 |
-
}
|
103 |
-
$i++;
|
104 |
-
}
|
105 |
-
}
|
106 |
-
|
107 |
-
return $instagram_items;
|
108 |
-
}
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
function getTagId($account_id, $access_token, $hashtag = null)
|
113 |
-
{
|
114 |
-
|
115 |
-
$response = $this->remoteGet("{$this->facebook_graph_url}/ig_hashtag_search", array(
|
116 |
-
'user_id' => $account_id,
|
117 |
-
'q' => urlencode($hashtag),
|
118 |
-
'access_token' => $access_token
|
119 |
-
));
|
120 |
-
|
121 |
-
if (isset($response['data'][0]['id'])) {
|
122 |
-
return $response['data'][0]['id'];
|
123 |
-
}
|
124 |
-
|
125 |
-
}
|
126 |
-
|
127 |
-
function getTagMedia($account_id, $hashtag = null, $after = null)
|
128 |
-
{
|
129 |
-
|
130 |
-
if (!$hashtag) {
|
131 |
-
$this->setMessage(esc_html__('Please update Instagram Tag in the feed settings.', 'insta-gallery'));
|
132 |
-
return;
|
133 |
-
}
|
134 |
-
|
135 |
-
if (!$account_id) {
|
136 |
-
$this->setMessage(esc_html__('Please update Instagram Account in the feed settings.', 'insta-gallery'));
|
137 |
-
return;
|
138 |
-
}
|
139 |
-
|
140 |
-
$account_model = new QLIGG_Account();
|
141 |
-
|
142 |
-
$account = $account_model->get_account($account_id);
|
143 |
-
|
144 |
-
if (!isset($account['access_token'])) {
|
145 |
-
$this->setMessage(esc_html__('Please update Instagram Access Token in the account settings.', 'insta-gallery'));
|
146 |
-
return;
|
147 |
-
}
|
148 |
-
|
149 |
-
if (!$hashtag_id = $this->getTagId($account['id'], $account['access_token'], $hashtag)) {
|
150 |
-
$this->setMessage(sprintf(esc_html__('Can\'t find the tag %s.', 'insta-gallery'), $hashtag));
|
151 |
-
return;
|
152 |
-
}
|
153 |
-
|
154 |
-
$limit = 30; //$num = min( $num, 200 );
|
155 |
-
$order_by = 'recent_media'; //top_media
|
156 |
-
|
157 |
-
$response = $this->remoteGet("{$this->facebook_graph_url}/{$hashtag_id}/{$order_by}", array(
|
158 |
-
'after' => $after,
|
159 |
-
'user_id' => $account['id'],
|
160 |
-
'limit' => $limit,
|
161 |
-
'fields' => 'media_url,caption,id,media_type,comments_count,like_count,permalink,children{media_url,id,media_type,permalink}',
|
162 |
-
'access_token' => $account['access_token']
|
163 |
-
));
|
164 |
-
|
165 |
-
return (array) $response;
|
166 |
-
}
|
167 |
-
|
168 |
-
function validateResponse($json = null)
|
169 |
-
{
|
170 |
-
|
171 |
-
if (!($response = json_decode(wp_remote_retrieve_body($json), true)) || 200 !== wp_remote_retrieve_response_code($json)) {
|
172 |
-
|
173 |
-
if (isset($response['error']['message'])) {
|
174 |
-
$this->message = $response['error']['message'];
|
175 |
-
return array(
|
176 |
-
'error' => 1,
|
177 |
-
'message' => $this->message
|
178 |
-
);
|
179 |
-
}
|
180 |
-
|
181 |
-
if (is_wp_error($json)) {
|
182 |
-
$response = array(
|
183 |
-
'error' => 1,
|
184 |
-
'message' => $json->get_error_message()
|
185 |
-
);
|
186 |
-
} else {
|
187 |
-
$response = array(
|
188 |
-
'error' => 1,
|
189 |
-
'message' => esc_html__('Unknow error occurred, please try again', 'insta-gallery')
|
190 |
-
);
|
191 |
-
}
|
192 |
-
}
|
193 |
-
|
194 |
-
return $response;
|
195 |
-
}
|
196 |
-
|
197 |
-
public function remoteGet($url = null, $args = array())
|
198 |
-
{
|
199 |
-
|
200 |
-
$url = add_query_arg($args, trailingslashit($url));
|
201 |
-
|
202 |
-
$response = $this->validateResponse(wp_remote_get($url, array('timeout' => 29)));
|
203 |
-
|
204 |
-
return $response;
|
205 |
-
}
|
206 |
-
|
207 |
-
// Return message
|
208 |
-
// ---------------------------------------------------------------------------
|
209 |
-
public function getMessage()
|
210 |
-
{
|
211 |
-
return $this->message;
|
212 |
-
}
|
213 |
-
|
214 |
-
public function setMessage($message = '')
|
215 |
-
{
|
216 |
-
$this->message = $message;
|
217 |
-
}
|
218 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/apiInstagram.php
DELETED
@@ -1,161 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if (!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
if (!class_exists('QLIGG_API_Instagram')) {
|
7 |
-
|
8 |
-
class QLIGG_API_Instagram
|
9 |
-
{
|
10 |
-
|
11 |
-
public $message;
|
12 |
-
public $instagram_id = '504270170253170';
|
13 |
-
public $instagram_url = 'https://www.instagram.com';
|
14 |
-
public $instagram_graph_url = 'https://graph.instagram.com';
|
15 |
-
public $instagram_redirect_uri = 'https://socialfeed.quadlayers.com/instagram.php';
|
16 |
-
|
17 |
-
function getAccessTokenLink()
|
18 |
-
{
|
19 |
-
|
20 |
-
$state = admin_url('admin.php');
|
21 |
-
$scope = 'user_profile,user_media';
|
22 |
-
|
23 |
-
return "{$this->instagram_url}/oauth/authorize?app_id={$this->instagram_id}&redirect_uri={$this->instagram_redirect_uri}&response_type=code&scope={$scope}&state={$state}";
|
24 |
-
}
|
25 |
-
|
26 |
-
function getUserProfile($access_token)
|
27 |
-
{
|
28 |
-
|
29 |
-
$response = $this->remoteGet("{$this->instagram_graph_url}/me", array(
|
30 |
-
'fields' => 'id,media_count,username,account_type',
|
31 |
-
'access_token' => $access_token
|
32 |
-
));
|
33 |
-
|
34 |
-
return (array) $response;
|
35 |
-
}
|
36 |
-
|
37 |
-
function getUserMedia($access_token, $after = null)
|
38 |
-
{
|
39 |
-
|
40 |
-
$limit = 60; //$num = min( $num, 200 );
|
41 |
-
|
42 |
-
$response = $this->remoteGet("{$this->instagram_graph_url}/me/media", array(
|
43 |
-
'after' => $after,
|
44 |
-
'limit' => $limit,
|
45 |
-
'fields' => 'media_url,thumbnail_url,caption,id,media_type,timestamp,username,comments_count,like_count,permalink,children{media_url,id,media_type,timestamp,permalink,thumbnail_url}',
|
46 |
-
'access_token' => $access_token
|
47 |
-
));
|
48 |
-
|
49 |
-
return (array) $response;
|
50 |
-
}
|
51 |
-
|
52 |
-
function setupMediaItems($data, $last_id = null)
|
53 |
-
{
|
54 |
-
|
55 |
-
static $load = false;
|
56 |
-
static $i = 1;
|
57 |
-
|
58 |
-
if (!$last_id) {
|
59 |
-
$load = true;
|
60 |
-
}
|
61 |
-
|
62 |
-
$instagram_items = array();
|
63 |
-
|
64 |
-
if (is_array($data) && !empty($data)) {
|
65 |
-
|
66 |
-
foreach ($data as $item) {
|
67 |
-
|
68 |
-
if ($load) {
|
69 |
-
|
70 |
-
preg_match_all('/(?<!\S)#([0-9a-zA-Z]+)/', @$item['caption'], $hashtags);
|
71 |
-
|
72 |
-
$media_url = ($item['media_type'] === 'CAROUSEL_ALBUM') ? @$item['children']['data'][0]['media_url'] : @$item['media_url'];
|
73 |
-
$date = isset($item['timestamp']) ? date_i18n('j F, Y', strtotime(trim(str_replace(array('T', '+', ' 0000'), ' ', $item['timestamp'])))) : false;
|
74 |
-
|
75 |
-
$test = $instagram_items[] = array(
|
76 |
-
'i' => $i,
|
77 |
-
'id' => $item['id'],
|
78 |
-
'type' => strtolower(str_replace('_ALBUM', '', $item['media_type'])),
|
79 |
-
'media' => $media_url,
|
80 |
-
'images' => array(
|
81 |
-
'standard' => "{$item['permalink']}media?size=l",
|
82 |
-
'medium' => "{$item['permalink']}media?size=m",
|
83 |
-
'small' => "{$item['permalink']}media?size=t",
|
84 |
-
),
|
85 |
-
'videos' => array(
|
86 |
-
'standard' => "{$item['permalink']}media?size=l",
|
87 |
-
'medium' => "{$item['permalink']}media?size=m",
|
88 |
-
'small' => "{$item['permalink']}media?size=t",
|
89 |
-
),
|
90 |
-
'likes' => isset($item['like_count']) ? $item['like_count'] : false,
|
91 |
-
'comments' => isset($item['comments_count']) ? $item['comments_count'] : false,
|
92 |
-
'caption' => preg_replace('/(?<!\S)#([0-9a-zA-Z]+)/', "<a href=\"{$this->instagram_url}/explore/tags/$1\">#$1</a>", htmlspecialchars(@$item['caption'])),
|
93 |
-
'hashtags' => @$hashtags[1], //array_map('utf8_encode', (array) @$hashtags[1]), // issue with uft 8 encode breakes json_encode
|
94 |
-
'link' => $item['permalink'],
|
95 |
-
'date' => $date
|
96 |
-
);
|
97 |
-
}
|
98 |
-
|
99 |
-
if ($last_id && ($last_id == $i)) {
|
100 |
-
$i = $last_id;
|
101 |
-
$load = true;
|
102 |
-
}
|
103 |
-
$i++;
|
104 |
-
}
|
105 |
-
}
|
106 |
-
|
107 |
-
return $instagram_items;
|
108 |
-
}
|
109 |
-
|
110 |
-
function validateResponse($json = null)
|
111 |
-
{
|
112 |
-
|
113 |
-
if (!($response = json_decode(wp_remote_retrieve_body($json), true)) || 200 !== wp_remote_retrieve_response_code($json)) {
|
114 |
-
|
115 |
-
if (isset($response['error']['message'])) {
|
116 |
-
$this->message = $response['error']['message'];
|
117 |
-
return array(
|
118 |
-
'error' => 1,
|
119 |
-
'message' => $this->message
|
120 |
-
);
|
121 |
-
}
|
122 |
-
|
123 |
-
if (is_wp_error($json)) {
|
124 |
-
$response = array(
|
125 |
-
'error' => 1,
|
126 |
-
'message' => $json->get_error_message()
|
127 |
-
);
|
128 |
-
} else {
|
129 |
-
$response = array(
|
130 |
-
'error' => 1,
|
131 |
-
'message' => esc_html__('Unknow error occurred, please try again', 'insta-gallery')
|
132 |
-
);
|
133 |
-
}
|
134 |
-
}
|
135 |
-
|
136 |
-
return $response;
|
137 |
-
}
|
138 |
-
|
139 |
-
public function remoteGet($url = null, $args = array())
|
140 |
-
{
|
141 |
-
|
142 |
-
$url = add_query_arg($args, trailingslashit($url));
|
143 |
-
|
144 |
-
$response = $this->validateResponse(wp_remote_get($url, array('timeout' => 29)));
|
145 |
-
|
146 |
-
return $response;
|
147 |
-
}
|
148 |
-
|
149 |
-
// Return message
|
150 |
-
// ---------------------------------------------------------------------------
|
151 |
-
public function getMessage()
|
152 |
-
{
|
153 |
-
return $this->message;
|
154 |
-
}
|
155 |
-
|
156 |
-
public function setMessage($message = '')
|
157 |
-
{
|
158 |
-
$this->message = $message;
|
159 |
-
}
|
160 |
-
}
|
161 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/compatibility.php
CHANGED
@@ -351,10 +351,10 @@ QLIGG_Compatibility::instance();
|
|
351 |
// -----------------------------------------------------------------------------
|
352 |
function qligg_get_user_items_old($user_id = null, $limit = 12, $next_max_id = null, $max_id = null) {
|
353 |
|
354 |
-
global $
|
355 |
|
356 |
if (!$user_id) {
|
357 |
-
$
|
358 |
return;
|
359 |
}
|
360 |
|
@@ -362,7 +362,7 @@ function qligg_get_user_items_old($user_id = null, $limit = 12, $next_max_id = n
|
|
362 |
$tokens = $token_model->get_tokens();
|
363 |
|
364 |
if (empty($tokens[$user_id])) {
|
365 |
-
$
|
366 |
return;
|
367 |
}
|
368 |
|
@@ -373,7 +373,7 @@ function qligg_get_user_items_old($user_id = null, $limit = 12, $next_max_id = n
|
|
373 |
|
374 |
// Get any existing copy of our transient data
|
375 |
if (QLIGG_DEVELOPER || false === ($response = get_transient($tk))) {
|
376 |
-
if ($response = $
|
377 |
set_transient($tk, $response, absint($settings['insta_reset']) * HOUR_IN_SECONDS);
|
378 |
}
|
379 |
}
|
@@ -382,7 +382,7 @@ function qligg_get_user_items_old($user_id = null, $limit = 12, $next_max_id = n
|
|
382 |
return;
|
383 |
}
|
384 |
|
385 |
-
if (count($feeds = $
|
386 |
return $feeds;
|
387 |
}
|
388 |
|
351 |
// -----------------------------------------------------------------------------
|
352 |
function qligg_get_user_items_old($user_id = null, $limit = 12, $next_max_id = null, $max_id = null) {
|
353 |
|
354 |
+
global $qliggAPI;
|
355 |
|
356 |
if (!$user_id) {
|
357 |
+
$qliggAPI->BASIC->set_message(esc_html__('Please update Instagram User in the gallery settings tab.', 'insta-gallery'));
|
358 |
return;
|
359 |
}
|
360 |
|
362 |
$tokens = $token_model->get_tokens();
|
363 |
|
364 |
if (empty($tokens[$user_id])) {
|
365 |
+
$qliggAPI->BASIC->set_message(esc_html__('Please update Instagram Access Token in the account settings tab.', 'insta-gallery'));
|
366 |
return;
|
367 |
}
|
368 |
|
373 |
|
374 |
// Get any existing copy of our transient data
|
375 |
if (QLIGG_DEVELOPER || false === ($response = get_transient($tk))) {
|
376 |
+
if ($response = $qliggAPI->BASIC->get_user_items($tokens[$user_id], $max_id)) {
|
377 |
set_transient($tk, $response, absint($settings['insta_reset']) * HOUR_IN_SECONDS);
|
378 |
}
|
379 |
}
|
382 |
return;
|
383 |
}
|
384 |
|
385 |
+
if (count($feeds = $qliggAPI->BASIC->setup_user_item($response['data'], $next_max_id, $max_id)) >= $limit) {
|
386 |
return $feeds;
|
387 |
}
|
388 |
|
includes/controllers/AccountController.php
CHANGED
@@ -39,7 +39,7 @@ class QLIGG_Account_Controller extends QLIGG_Controller
|
|
39 |
|
40 |
function add_panel()
|
41 |
{
|
42 |
-
global $submenu, $
|
43 |
$account_model = new QLIGG_Account();
|
44 |
$accounts = $account_model->get_accounts();
|
45 |
|
39 |
|
40 |
function add_panel()
|
41 |
{
|
42 |
+
global $submenu, $qliggAPI;
|
43 |
$account_model = new QLIGG_Account();
|
44 |
$accounts = $account_model->get_accounts();
|
45 |
|
includes/controllers/FeedController.php
CHANGED
@@ -16,7 +16,7 @@ class QLIGG_Feed_Controller extends QLIGG_Controller
|
|
16 |
|
17 |
function add_panel()
|
18 |
{
|
19 |
-
global $submenu, $
|
20 |
$feed_model = new QLIGG_Feed();
|
21 |
$feeds = $feed_model->get_feeds();
|
22 |
$account_model = new QLIGG_Account();
|
16 |
|
17 |
function add_panel()
|
18 |
{
|
19 |
+
global $submenu, $qliggAPI;
|
20 |
$feed_model = new QLIGG_Feed();
|
21 |
$feeds = $feed_model->get_feeds();
|
22 |
$account_model = new QLIGG_Account();
|
includes/frontend.php
CHANGED
@@ -39,7 +39,6 @@ if (!class_exists('QLIGG_Frontend')) {
|
|
39 |
|
40 |
function get_items($feed = false, $next_max_id = false)
|
41 |
{
|
42 |
-
|
43 |
if (isset($feed['type'])) {
|
44 |
|
45 |
if ($feed['type'] == 'username') {
|
@@ -47,7 +46,7 @@ if (!class_exists('QLIGG_Frontend')) {
|
|
47 |
}
|
48 |
|
49 |
if ($feed['type'] == 'tag') {
|
50 |
-
return qligg_get_tag_items($feed
|
51 |
}
|
52 |
}
|
53 |
|
@@ -57,7 +56,7 @@ if (!class_exists('QLIGG_Frontend')) {
|
|
57 |
function ajax_load_item_images()
|
58 |
{
|
59 |
|
60 |
-
global $
|
61 |
|
62 |
if (!isset($_REQUEST['feed'])) {
|
63 |
wp_send_json_error(esc_html__('Invalid item id', 'insta-gallery'));
|
@@ -98,9 +97,7 @@ if (!class_exists('QLIGG_Frontend')) {
|
|
98 |
wp_send_json_success(ob_get_clean());
|
99 |
}
|
100 |
|
101 |
-
$messages =
|
102 |
-
$qligg_instagram->getMessage()
|
103 |
-
);
|
104 |
|
105 |
include($this->template_path('alert.php'));
|
106 |
|
@@ -124,7 +121,7 @@ if (!class_exists('QLIGG_Frontend')) {
|
|
124 |
function do_shortcode($atts, $content = null)
|
125 |
{
|
126 |
|
127 |
-
global $
|
128 |
|
129 |
$feed_model = new QLIGG_Feed();
|
130 |
$feeds = $feed_model->get_feeds();
|
@@ -150,11 +147,11 @@ if (!class_exists('QLIGG_Frontend')) {
|
|
150 |
|
151 |
$profile_info = $feed['profile'];
|
152 |
|
153 |
-
if ($feed['type'] == 'username') {
|
154 |
$profile_info = qligg_get_user_profile($feed['username']);
|
155 |
|
156 |
-
$feed['profile'] = array_merge($profile_info, $feed['profile']);
|
157 |
-
}
|
158 |
|
159 |
}
|
160 |
|
39 |
|
40 |
function get_items($feed = false, $next_max_id = false)
|
41 |
{
|
|
|
42 |
if (isset($feed['type'])) {
|
43 |
|
44 |
if ($feed['type'] == 'username') {
|
46 |
}
|
47 |
|
48 |
if ($feed['type'] == 'tag') {
|
49 |
+
return qligg_get_tag_items($feed, $next_max_id);
|
50 |
}
|
51 |
}
|
52 |
|
56 |
function ajax_load_item_images()
|
57 |
{
|
58 |
|
59 |
+
global $qliggAPI;
|
60 |
|
61 |
if (!isset($_REQUEST['feed'])) {
|
62 |
wp_send_json_error(esc_html__('Invalid item id', 'insta-gallery'));
|
97 |
wp_send_json_success(ob_get_clean());
|
98 |
}
|
99 |
|
100 |
+
$messages = $qliggAPI->FEED->getMessages();
|
|
|
|
|
101 |
|
102 |
include($this->template_path('alert.php'));
|
103 |
|
121 |
function do_shortcode($atts, $content = null)
|
122 |
{
|
123 |
|
124 |
+
global $qliggAPI;
|
125 |
|
126 |
$feed_model = new QLIGG_Feed();
|
127 |
$feeds = $feed_model->get_feeds();
|
147 |
|
148 |
$profile_info = $feed['profile'];
|
149 |
|
150 |
+
//if ($feed['type'] == 'username') {
|
151 |
$profile_info = qligg_get_user_profile($feed['username']);
|
152 |
|
153 |
+
$feed['profile'] = array_merge($profile_info, array_filter($feed['profile']));
|
154 |
+
//}
|
155 |
|
156 |
}
|
157 |
|
includes/helpers.php
CHANGED
@@ -6,7 +6,7 @@ include_once(QLIGG_PLUGIN_DIR . 'includes/models/Setting.php');
|
|
6 |
function qligg_sanitize_instagram_feed($feed)
|
7 |
{
|
8 |
|
9 |
-
global $
|
10 |
|
11 |
// Removing @, # and trimming input
|
12 |
// ---------------------------------------------------------------------
|
@@ -16,7 +16,7 @@ function qligg_sanitize_instagram_feed($feed)
|
|
16 |
$feed = trim($feed);
|
17 |
$feed = str_replace('@', '', $feed);
|
18 |
$feed = str_replace('#', '', $feed);
|
19 |
-
$feed = str_replace($
|
20 |
$feed = str_replace('/explore/tags/', '', $feed);
|
21 |
$feed = str_replace('/', '', $feed);
|
22 |
|
@@ -28,7 +28,7 @@ function qligg_sanitize_instagram_feed($feed)
|
|
28 |
function qligg_get_user_profile($account_id = null)
|
29 |
{
|
30 |
|
31 |
-
global $
|
32 |
|
33 |
$defaults = array(
|
34 |
'id' => $account_id,
|
@@ -66,16 +66,16 @@ function qligg_get_user_profile($account_id = null)
|
|
66 |
//validate token based on type
|
67 |
|
68 |
if ($account['token_type'] === 'BASIC') {
|
69 |
-
$_profile_info = $
|
70 |
$_profile_info['name'] = __('This token expires soon!');
|
71 |
}
|
72 |
|
73 |
if ($account['token_type'] === 'PERSONAL') {
|
74 |
-
$_profile_info = $
|
75 |
}
|
76 |
|
77 |
if ($account['token_type'] === 'BUSINESS') {
|
78 |
-
$_profile_info = $
|
79 |
}
|
80 |
|
81 |
$settings_model = new QLIGG_Setting();
|
@@ -93,7 +93,7 @@ function qligg_get_user_profile($account_id = null)
|
|
93 |
function qligg_get_tag_profile($hashtag = null)
|
94 |
{
|
95 |
|
96 |
-
global $
|
97 |
|
98 |
$defaults = array(
|
99 |
'id' => '',
|
@@ -101,7 +101,7 @@ function qligg_get_tag_profile($hashtag = null)
|
|
101 |
'username' => $hashtag,
|
102 |
'name' => $hashtag,
|
103 |
'profile_picture_url' => 'http://2.gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=150&d=mm&r=g',
|
104 |
-
'link' => "{$
|
105 |
);
|
106 |
|
107 |
if (empty($hashtag)) {
|
@@ -114,7 +114,7 @@ function qligg_get_tag_profile($hashtag = null)
|
|
114 |
return wp_parse_args($profile_info, $defaults);
|
115 |
}
|
116 |
|
117 |
-
// if (!$hashtag_id = $
|
118 |
// return $defaults;
|
119 |
// }
|
120 |
|
@@ -138,10 +138,10 @@ function qligg_get_tag_profile($hashtag = null)
|
|
138 |
function qligg_get_user_media($account_id = null, $limit = 12, $last_id = null, $after = null)
|
139 |
{
|
140 |
|
141 |
-
global $
|
142 |
|
143 |
if (!$account_id) {
|
144 |
-
$
|
145 |
return;
|
146 |
}
|
147 |
|
@@ -150,27 +150,29 @@ function qligg_get_user_media($account_id = null, $limit = 12, $last_id = null,
|
|
150 |
$account = $account_model->get_account($account_id);
|
151 |
|
152 |
if (!isset($account['access_token'])) {
|
153 |
-
$
|
154 |
return;
|
155 |
}
|
156 |
|
157 |
// compatibility with 2.7.1
|
158 |
// ---------------------------------------------------------------------------
|
159 |
-
if ($account['token_type'] === 'BASIC' && $
|
160 |
return qligg_get_user_items_old($account_id, $limit, $last_id, $after);
|
161 |
}
|
162 |
|
163 |
-
$
|
|
|
|
|
164 |
|
165 |
// Get any existing copy of our transient data
|
166 |
if (QLIGG_DEVELOPER || false === ($response = get_transient($tk))) {
|
167 |
|
168 |
if ($account['token_type'] === 'PERSONAL') {
|
169 |
-
$response = $
|
170 |
}
|
171 |
|
172 |
if ($account['token_type'] === 'BUSINESS') {
|
173 |
-
$response = $
|
174 |
}
|
175 |
|
176 |
if (!isset($response['data'])) {
|
@@ -187,7 +189,7 @@ function qligg_get_user_media($account_id = null, $limit = 12, $last_id = null,
|
|
187 |
set_transient($tk, $response, absint($settings['insta_reset']) * HOUR_IN_SECONDS);
|
188 |
}
|
189 |
|
190 |
-
$feeds = $
|
191 |
|
192 |
if (!$last_id) {
|
193 |
return $feeds;
|
@@ -207,24 +209,35 @@ function qligg_get_user_media($account_id = null, $limit = 12, $last_id = null,
|
|
207 |
|
208 |
$after = $response['paging']['cursors']['after'];
|
209 |
|
210 |
-
|
|
|
|
|
|
|
|
|
211 |
}
|
212 |
|
213 |
// Get tag items
|
214 |
// ----------------------------------------------------------------------------
|
215 |
//function qligg_get_user_media($account_id = null, $limit = 12, $last_id = null, $after = null) {
|
216 |
|
217 |
-
function qligg_get_tag_items($
|
218 |
{
|
219 |
|
220 |
-
global $
|
|
|
|
|
|
|
|
|
|
|
221 |
|
222 |
-
$
|
|
|
|
|
223 |
|
224 |
// Get any existing copy of our transient data
|
225 |
if (QLIGG_DEVELOPER || false === ($response = get_transient($tk))) {
|
226 |
|
227 |
-
$response = $
|
228 |
|
229 |
if (!isset($response['data'])) {
|
230 |
return;
|
@@ -240,7 +253,7 @@ function qligg_get_tag_items($account_id = null, $hashtag = null, $limit = 12, $
|
|
240 |
set_transient($tk, $response, absint($settings['insta_reset']) * HOUR_IN_SECONDS);
|
241 |
}
|
242 |
|
243 |
-
$feeds = $
|
244 |
|
245 |
if (!$last_id) {
|
246 |
return $feeds;
|
@@ -260,5 +273,9 @@ function qligg_get_tag_items($account_id = null, $hashtag = null, $limit = 12, $
|
|
260 |
|
261 |
$after = $response['paging']['cursors']['after'];
|
262 |
|
263 |
-
|
|
|
|
|
|
|
|
|
264 |
}
|
6 |
function qligg_sanitize_instagram_feed($feed)
|
7 |
{
|
8 |
|
9 |
+
global $qliggAPI;
|
10 |
|
11 |
// Removing @, # and trimming input
|
12 |
// ---------------------------------------------------------------------
|
16 |
$feed = trim($feed);
|
17 |
$feed = str_replace('@', '', $feed);
|
18 |
$feed = str_replace('#', '', $feed);
|
19 |
+
$feed = str_replace($qliggAPI->FEED->instagram_url, '', $feed);
|
20 |
$feed = str_replace('/explore/tags/', '', $feed);
|
21 |
$feed = str_replace('/', '', $feed);
|
22 |
|
28 |
function qligg_get_user_profile($account_id = null)
|
29 |
{
|
30 |
|
31 |
+
global $qliggAPI;
|
32 |
|
33 |
$defaults = array(
|
34 |
'id' => $account_id,
|
66 |
//validate token based on type
|
67 |
|
68 |
if ($account['token_type'] === 'BASIC') {
|
69 |
+
$_profile_info = $qliggAPI->BASIC->get_user_profile($account['access_token']);
|
70 |
$_profile_info['name'] = __('This token expires soon!');
|
71 |
}
|
72 |
|
73 |
if ($account['token_type'] === 'PERSONAL') {
|
74 |
+
$_profile_info = $qliggAPI->PERSONAL->getUserProfile($account['access_token']);
|
75 |
}
|
76 |
|
77 |
if ($account['token_type'] === 'BUSINESS') {
|
78 |
+
$_profile_info = $qliggAPI->BUSINESS->getUserProfile($account_id, $account['access_token']);
|
79 |
}
|
80 |
|
81 |
$settings_model = new QLIGG_Setting();
|
93 |
function qligg_get_tag_profile($hashtag = null)
|
94 |
{
|
95 |
|
96 |
+
global $qliggAPI;
|
97 |
|
98 |
$defaults = array(
|
99 |
'id' => '',
|
101 |
'username' => $hashtag,
|
102 |
'name' => $hashtag,
|
103 |
'profile_picture_url' => 'http://2.gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=150&d=mm&r=g',
|
104 |
+
'link' => "{$qliggAPI->FEED->instagram_url}/explore/tags/{$hashtag}"
|
105 |
);
|
106 |
|
107 |
if (empty($hashtag)) {
|
114 |
return wp_parse_args($profile_info, $defaults);
|
115 |
}
|
116 |
|
117 |
+
// if (!$hashtag_id = $qliggAPI->BUSINESS->getTagId($hashtag)) {
|
118 |
// return $defaults;
|
119 |
// }
|
120 |
|
138 |
function qligg_get_user_media($account_id = null, $limit = 12, $last_id = null, $after = null)
|
139 |
{
|
140 |
|
141 |
+
global $qliggAPI;
|
142 |
|
143 |
if (!$account_id) {
|
144 |
+
$qliggAPI->FEED->setMessage(esc_html__('Please update Instagram User in the feed settings.', 'insta-gallery'));
|
145 |
return;
|
146 |
}
|
147 |
|
150 |
$account = $account_model->get_account($account_id);
|
151 |
|
152 |
if (!isset($account['access_token'])) {
|
153 |
+
$qliggAPI->FEED->setMessage(esc_html__('Please update Instagram Access Token in the account settings.', 'insta-gallery'));
|
154 |
return;
|
155 |
}
|
156 |
|
157 |
// compatibility with 2.7.1
|
158 |
// ---------------------------------------------------------------------------
|
159 |
+
if ($account['token_type'] === 'BASIC' && $qliggAPI->BASIC->validate_token($account['access_token'])) {
|
160 |
return qligg_get_user_items_old($account_id, $limit, $last_id, $after);
|
161 |
}
|
162 |
|
163 |
+
$md5 = hash('md5', $after);
|
164 |
+
|
165 |
+
$tk = "insta_gallery_v2_user_media_{$account_id}_{$md5}";
|
166 |
|
167 |
// Get any existing copy of our transient data
|
168 |
if (QLIGG_DEVELOPER || false === ($response = get_transient($tk))) {
|
169 |
|
170 |
if ($account['token_type'] === 'PERSONAL') {
|
171 |
+
$response = $qliggAPI->PERSONAL->getUserMedia($account['access_token'], $after);
|
172 |
}
|
173 |
|
174 |
if ($account['token_type'] === 'BUSINESS') {
|
175 |
+
$response = $qliggAPI->BUSINESS->getUserMedia($account_id, $account['access_token'], $after);
|
176 |
}
|
177 |
|
178 |
if (!isset($response['data'])) {
|
189 |
set_transient($tk, $response, absint($settings['insta_reset']) * HOUR_IN_SECONDS);
|
190 |
}
|
191 |
|
192 |
+
$feeds = $qliggAPI->PERSONAL->setupMediaItems($response['data'], $last_id);
|
193 |
|
194 |
if (!$last_id) {
|
195 |
return $feeds;
|
209 |
|
210 |
$after = $response['paging']['cursors']['after'];
|
211 |
|
212 |
+
if ($new_feeds = qligg_get_user_media($account_id, $limit, $last_id, $after)) {
|
213 |
+
$feeds = array_merge($feeds, (array) $new_feeds);
|
214 |
+
}
|
215 |
+
|
216 |
+
return $feeds;
|
217 |
}
|
218 |
|
219 |
// Get tag items
|
220 |
// ----------------------------------------------------------------------------
|
221 |
//function qligg_get_user_media($account_id = null, $limit = 12, $last_id = null, $after = null) {
|
222 |
|
223 |
+
function qligg_get_tag_items($feed, $last_id = null, $after = null)
|
224 |
{
|
225 |
|
226 |
+
global $qliggAPI;
|
227 |
+
|
228 |
+
$account_id = $feed['username'];
|
229 |
+
$tag = $feed['tag'];
|
230 |
+
$limit = $feed['limit'];
|
231 |
+
$order_by = $feed['order_by'];
|
232 |
|
233 |
+
$md5 = hash('md5', $after);
|
234 |
+
|
235 |
+
$tk = "insta_gallery_v2_tag_media_{$tag}_{$order_by}_{$md5}";
|
236 |
|
237 |
// Get any existing copy of our transient data
|
238 |
if (QLIGG_DEVELOPER || false === ($response = get_transient($tk))) {
|
239 |
|
240 |
+
$response = $qliggAPI->BUSINESS->getTagMedia($account_id, $tag, $order_by, $after);
|
241 |
|
242 |
if (!isset($response['data'])) {
|
243 |
return;
|
253 |
set_transient($tk, $response, absint($settings['insta_reset']) * HOUR_IN_SECONDS);
|
254 |
}
|
255 |
|
256 |
+
$feeds = $qliggAPI->BUSINESS->setupMediaItems($response['data'], $last_id);
|
257 |
|
258 |
if (!$last_id) {
|
259 |
return $feeds;
|
273 |
|
274 |
$after = $response['paging']['cursors']['after'];
|
275 |
|
276 |
+
if ($new_feeds = qligg_get_tag_items($account_id, $tag, $limit, $last_id, $after)) {
|
277 |
+
$feeds = array_merge($feeds, (array) $new_feeds);
|
278 |
+
}
|
279 |
+
|
280 |
+
return $feeds;
|
281 |
}
|
includes/models/Feed.php
CHANGED
@@ -15,6 +15,7 @@ class QLIGG_Feed extends QLIGG_Model
|
|
15 |
'username' => '', // rename to account_id
|
16 |
'type' => 'username',
|
17 |
'tag' => 'wordpress',
|
|
|
18 |
'layout' => 'gallery',
|
19 |
'limit' => 12,
|
20 |
'columns' => 3,
|
15 |
'username' => '', // rename to account_id
|
16 |
'type' => 'username',
|
17 |
'tag' => 'wordpress',
|
18 |
+
'order_by' => 'top_media',
|
19 |
'layout' => 'gallery',
|
20 |
'limit' => 12,
|
21 |
'columns' => 3,
|
includes/qligg.php
CHANGED
@@ -43,28 +43,20 @@ class QLIGG
|
|
43 |
function api()
|
44 |
{
|
45 |
|
46 |
-
global $
|
47 |
|
48 |
-
|
|
|
|
|
|
|
|
|
49 |
|
50 |
-
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
include_once(QLIGG_PLUGIN_DIR . 'includes/apiInstagram.php');
|
58 |
-
|
59 |
-
$qligg_instagram = new QLIGG_API_Instagram();
|
60 |
-
}
|
61 |
-
|
62 |
-
if (!class_exists('QLIGG_API_Facebook')) {
|
63 |
-
|
64 |
-
include_once(QLIGG_PLUGIN_DIR . 'includes/apiFacebook.php');
|
65 |
-
|
66 |
-
$qligg_facebook = new QLIGG_API_Facebook();
|
67 |
-
}
|
68 |
}
|
69 |
|
70 |
public static function do_activation()
|
43 |
function api()
|
44 |
{
|
45 |
|
46 |
+
global $qliggAPI;
|
47 |
|
48 |
+
include_once(QLIGG_PLUGIN_DIR . 'includes/api/api.php');
|
49 |
+
include_once(QLIGG_PLUGIN_DIR . 'includes/api/apiFeed.php');
|
50 |
+
include_once(QLIGG_PLUGIN_DIR . 'includes/api/apiBasic.php');
|
51 |
+
include_once(QLIGG_PLUGIN_DIR . 'includes/api/apiPersonal.php');
|
52 |
+
include_once(QLIGG_PLUGIN_DIR . 'includes/api/apiBusiness.php');
|
53 |
|
54 |
+
$qliggAPI = new stdClass();
|
55 |
|
56 |
+
$qliggAPI->FEED = QLIGG_API_Feed::instance();
|
57 |
+
$qliggAPI->BASIC = QLIGG_API_Basic::instance();
|
58 |
+
$qliggAPI->PERSONAL = QLIGG_API_Personal::instance();
|
59 |
+
$qliggAPI->BUSINESS = QLIGG_API_Business::instance();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
}
|
61 |
|
62 |
public static function do_activation()
|
includes/view/backend/pages/accounts.php
CHANGED
@@ -4,14 +4,14 @@
|
|
4 |
if (is_array($accounts) && count($accounts)) {
|
5 |
echo 'qligg-premium-field';
|
6 |
}
|
7 |
-
?>" id="qligg-generate-token" target="_self" href="<?php echo esc_url($
|
8 |
<?php esc_html_e('Add Personal Account', 'insta-gallery'); ?>
|
9 |
</a>
|
10 |
<a class="<?php
|
11 |
if (is_array($accounts) && count($accounts)) {
|
12 |
echo 'qligg-premium-field';
|
13 |
}
|
14 |
-
?>" id="qligg-generate-token" target="_self" href="<?php echo esc_url($
|
15 |
<?php esc_html_e('Add Business Account', 'insta-gallery'); ?>
|
16 |
</a>
|
17 |
<!-- <span style="float: none; margin-top: 0;" class="spinner"></span> -->
|
4 |
if (is_array($accounts) && count($accounts)) {
|
5 |
echo 'qligg-premium-field';
|
6 |
}
|
7 |
+
?>" id="qligg-generate-token" target="_self" href="<?php echo esc_url($qliggAPI->PERSONAL->getAccessTokenLink()); ?>" title="<?php esc_html_e('Add Personal Account', 'insta-gallery'); ?>">
|
8 |
<?php esc_html_e('Add Personal Account', 'insta-gallery'); ?>
|
9 |
</a>
|
10 |
<a class="<?php
|
11 |
if (is_array($accounts) && count($accounts)) {
|
12 |
echo 'qligg-premium-field';
|
13 |
}
|
14 |
+
?>" id="qligg-generate-token" target="_self" href="<?php echo esc_url($qliggAPI->BUSINESS->getAccessTokenLink()); ?>" title="<?php esc_html_e('Add Business Account', 'insta-gallery'); ?>">
|
15 |
<?php esc_html_e('Add Business Account', 'insta-gallery'); ?>
|
16 |
</a>
|
17 |
<!-- <span style="float: none; margin-top: 0;" class="spinner"></span> -->
|
includes/view/backend/pages/modals/feed/panel-feed-image-mask.php
CHANGED
@@ -17,7 +17,7 @@
|
|
17 |
</p>
|
18 |
</div>
|
19 |
|
20 |
-
<div class="<# if ( data.
|
21 |
<p class="form-field">
|
22 |
<label><?php esc_html_e('Images mask likes', 'insta-gallery'); ?></label>
|
23 |
<input name="mask[likes]" type="checkbox" value="true" <# if (data.mask.likes ){ #>checked<# } #>/>
|
@@ -29,7 +29,7 @@
|
|
29 |
<input name="mask[comments]" type="checkbox" value="true" <# if (data.mask.comments ){ #>checked<# } #>/>
|
30 |
<span class="description"><small><?php esc_html_e('Display comments count of images', 'insta-gallery'); ?></small></span>
|
31 |
</p>
|
32 |
-
<p class="form-field">
|
33 |
Instagram is deprecating their old API for Personal accounts on June 29, 2020. The plugin supports their new API, however, some features (such as this one) are not yet available in their new API. We're working to get this feature back as soon as possible.
|
34 |
</p>
|
35 |
</div>
|
17 |
</p>
|
18 |
</div>
|
19 |
|
20 |
+
<div class="<# if (data.username && qligg_feed.accounts[data.username] && qligg_feed.accounts[data.username].token_type!='BUSINESS') {#>disabled-feature<#}#> options_group <# if (!data.mask.display){ #>disabled-field<# } #>">
|
21 |
<p class="form-field">
|
22 |
<label><?php esc_html_e('Images mask likes', 'insta-gallery'); ?></label>
|
23 |
<input name="mask[likes]" type="checkbox" value="true" <# if (data.mask.likes ){ #>checked<# } #>/>
|
29 |
<input name="mask[comments]" type="checkbox" value="true" <# if (data.mask.comments ){ #>checked<# } #>/>
|
30 |
<span class="description"><small><?php esc_html_e('Display comments count of images', 'insta-gallery'); ?></small></span>
|
31 |
</p>
|
32 |
+
<p class="form-field <# if (data.username && qligg_feed.accounts[data.username] && qligg_feed.accounts[data.username].token_type=='BUSINESS') {#>hidden<#}#>">
|
33 |
Instagram is deprecating their old API for Personal accounts on June 29, 2020. The plugin supports their new API, however, some features (such as this one) are not yet available in their new API. We're working to get this feature back as soon as possible.
|
34 |
</p>
|
35 |
</div>
|
includes/view/backend/pages/modals/feed/panel-feed-image-popup.php
CHANGED
@@ -26,7 +26,7 @@
|
|
26 |
</p>
|
27 |
</div>
|
28 |
|
29 |
-
<div class="<# if ( data.
|
30 |
<p class="form-field">
|
31 |
<label><?php esc_html_e('Images popup likes', 'insta-gallery'); ?></label>
|
32 |
<input name="popup[likes]" type="checkbox" value="true" <# if (data.popup.likes){ #>checked<# } #>/>
|
@@ -39,7 +39,7 @@
|
|
39 |
<span class="description"><small><?php esc_html_e('Display comments count of images', 'insta-gallery'); ?></small></span>
|
40 |
<span class="description hidden"><small><?php esc_html_e('(This is a premium feature)', 'insta-gallery'); ?></small></span>
|
41 |
</p>
|
42 |
-
<p class="form-field">
|
43 |
Instagram is deprecating their old API for Personal accounts on June 29, 2020. The plugin supports their new API, however, some features (such as this one) are not yet available in their new API. We're working to get this feature back as soon as possible.
|
44 |
</p>
|
45 |
</div>
|
26 |
</p>
|
27 |
</div>
|
28 |
|
29 |
+
<div class="options_group qligg-premium-field <# if (!data.popup.display){ #>disabled-field<# } #> <# if (data.username && qligg_feed.accounts[data.username] && qligg_feed.accounts[data.username].token_type!='BUSINESS') {#>disabled-feature<#}#> options_group <# if (!data.mask.display){ #>disabled-field<# } #>">
|
30 |
<p class="form-field">
|
31 |
<label><?php esc_html_e('Images popup likes', 'insta-gallery'); ?></label>
|
32 |
<input name="popup[likes]" type="checkbox" value="true" <# if (data.popup.likes){ #>checked<# } #>/>
|
39 |
<span class="description"><small><?php esc_html_e('Display comments count of images', 'insta-gallery'); ?></small></span>
|
40 |
<span class="description hidden"><small><?php esc_html_e('(This is a premium feature)', 'insta-gallery'); ?></small></span>
|
41 |
</p>
|
42 |
+
<p class="form-field <# if (data.username && qligg_feed.accounts[data.username] && qligg_feed.accounts[data.username].token_type=='BUSINESS') {#>hidden<#}#>">
|
43 |
Instagram is deprecating their old API for Personal accounts on June 29, 2020. The plugin supports their new API, however, some features (such as this one) are not yet available in their new API. We're working to get this feature back as soon as possible.
|
44 |
</p>
|
45 |
</div>
|
includes/view/backend/pages/modals/feed/panel-feed.php
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
|
11 |
<p class="form-field">
|
12 |
<label><?php esc_html_e('Account', 'insta-gallery'); ?></label>
|
13 |
-
<select name="username" <# if ( data.username=='username' ) {#>required="required"<#}#>>
|
14 |
<?php foreach ($accounts as $account_id => $account) : ?>
|
15 |
<?php $profile_info = qligg_get_user_profile($account_id); ?>
|
16 |
<option value="<?php echo esc_attr($account_id) ?>" <# if ( data.username==<?php echo $account_id; ?> ) { #>selected="selected"<# } #> > <?php echo esc_html($profile_info['username']); ?></option>
|
@@ -19,7 +19,6 @@
|
|
19 |
<span class="description"><small><?php esc_html_e('Please select Instagram account', 'insta-gallery'); ?></small></span>
|
20 |
</p>
|
21 |
|
22 |
-
|
23 |
<# if (data.username && !qligg_feed.accounts[data.username]){ #>
|
24 |
<p class="form-field">
|
25 |
<span class="notice error" style="margin-left:0; margin-right:0; padding-top: 10px; padding-bottom: 10px; display: flex; justify-content: left; align-items: center;">
|
@@ -40,96 +39,117 @@
|
|
40 |
|
41 |
</div>
|
42 |
|
43 |
-
<# if (data.type
|
44 |
-
|
45 |
-
|
46 |
-
<
|
47 |
-
|
48 |
-
|
49 |
-
<
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
<p class="form-field">
|
57 |
<span class="notice error" style="margin-left:0; margin-right:0; padding-top: 10px; padding-bottom: 10px; display: flex; justify-content: left; align-items: center;">
|
58 |
<strong>
|
59 |
-
<?php
|
60 |
</strong>
|
61 |
</span>
|
62 |
</p>
|
63 |
-
|
64 |
-
</div>
|
65 |
-
<# } #>
|
66 |
|
67 |
-
|
68 |
-
<
|
69 |
-
<
|
70 |
-
<
|
71 |
-
<
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
<input type="radio" name="layout" value="carousel" <# if (data.layout== 'carousel'){ #>checked<# } #> />
|
77 |
<label for="insta_layout-carousel"><?php esc_html_e('Carousel', 'insta-gallery'); ?></label>
|
78 |
<img src="<?php echo plugins_url('/assets/backend/img/carousel.png', QLIGG_PLUGIN_FILE); ?>"/>
|
79 |
</li>
|
80 |
<li class="media-modal-image qligg-premium-field <# if ( data.layout == 'masonry') {#>active<#}#>">
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
|
135 |
</div>
|
10 |
|
11 |
<p class="form-field">
|
12 |
<label><?php esc_html_e('Account', 'insta-gallery'); ?></label>
|
13 |
+
<select class="media-modal-render-panels" name="username" <# if ( data.username=='username' ) {#>required="required"<#}#>>
|
14 |
<?php foreach ($accounts as $account_id => $account) : ?>
|
15 |
<?php $profile_info = qligg_get_user_profile($account_id); ?>
|
16 |
<option value="<?php echo esc_attr($account_id) ?>" <# if ( data.username==<?php echo $account_id; ?> ) { #>selected="selected"<# } #> > <?php echo esc_html($profile_info['username']); ?></option>
|
19 |
<span class="description"><small><?php esc_html_e('Please select Instagram account', 'insta-gallery'); ?></small></span>
|
20 |
</p>
|
21 |
|
|
|
22 |
<# if (data.username && !qligg_feed.accounts[data.username]){ #>
|
23 |
<p class="form-field">
|
24 |
<span class="notice error" style="margin-left:0; margin-right:0; padding-top: 10px; padding-bottom: 10px; display: flex; justify-content: left; align-items: center;">
|
39 |
|
40 |
</div>
|
41 |
|
42 |
+
<div class="options_group <# if ( data.type != 'tag') {#>hidden<#}#>">
|
43 |
+
<# if ( data.username && qligg_feed.accounts[data.username] && qligg_feed.accounts[data.username].token_type=='BUSINESS' ){ #>
|
44 |
+
<p class="form-field">
|
45 |
+
<label><?php esc_html_e('Tag', 'insta-gallery'); ?></label>
|
46 |
+
<input name="tag" type="text" <# if ( data.type=='tag' ) {#>required="required"<#}#> placeholder="beautiful" value="{{data.tag}}" />
|
47 |
+
<span class="description">
|
48 |
+
<small>
|
49 |
+
<?php esc_html_e('Please enter Instagram tag', 'insta-gallery'); ?>
|
50 |
+
</small>
|
51 |
+
</span>
|
52 |
+
</p>
|
53 |
+
<p class="form-field">
|
54 |
+
<label><?php esc_html_e('Order by', 'insta-gallery'); ?></label>
|
55 |
+
<select class="media-modal-render-panels" name="order_by" <# if ( data.username=='username' ) {#>required="required"<#}#>>
|
56 |
+
<option value="recent_media" <# if ( data.order_by=='recend_media' ) { #>selected="selected"<# } #> ><?php echo esc_html('Recent (Within 24 hours)', 'insta-gallery'); ?></option>
|
57 |
+
<option value="top_media" <# if ( data.order_by=='top_media' ) { #>selected="selected"<# } #> ><?php echo esc_html('Top (Most popular first)', 'insta-gallery'); ?></option>
|
58 |
+
</select>
|
59 |
+
<span class="description">
|
60 |
+
<small>
|
61 |
+
<?php esc_html_e('Please enter Instagram tag order', 'insta-gallery'); ?>
|
62 |
+
</small>
|
63 |
+
</span>
|
64 |
+
</p>
|
65 |
+
|
66 |
+
<# if(data.order_by=='recent_media' ) { #>
|
67 |
<p class="form-field">
|
68 |
<span class="notice error" style="margin-left:0; margin-right:0; padding-top: 10px; padding-bottom: 10px; display: flex; justify-content: left; align-items: center;">
|
69 |
<strong>
|
70 |
+
<?php esc_html_e('Due to the restrictions of the new Instagram API the recent order will only return the most recent images from the past 24 hours.', 'insta-gallery'); ?>
|
71 |
</strong>
|
72 |
</span>
|
73 |
</p>
|
74 |
+
<# } #>
|
|
|
|
|
75 |
|
76 |
+
<# } else { #>
|
77 |
+
<p class="form-field">
|
78 |
+
<span class="notice error" style="margin-left:0; margin-right:0; padding-top: 10px; padding-bottom: 10px; display: flex; justify-content: left; align-items: center;">
|
79 |
+
<strong>
|
80 |
+
<?php printf(__('Due to the restrictions of the new Instagram <a target="_blank" href="%s">API</a> it is necessary to connect a business account <a href="%s">here</a>.', 'insta-gallery'), 'https://quadlayers.com/documentation/instagram-feed-gallery/api/business/?utm_source=qligg_admin', admin_url('admin.php?page=qligg_account')); ?>
|
81 |
+
</strong>
|
82 |
+
</span>
|
83 |
+
</p>
|
84 |
+
<# } #>
|
85 |
+
</div>
|
86 |
+
|
87 |
+
<div class="options_group">
|
88 |
+
<div class="form-field">
|
89 |
+
<ul class="list-images">
|
90 |
+
<li class="media-modal-image <# if ( data.layout == 'gallery') {#>active<#}#>">
|
91 |
+
<input type="radio" name="layout" value="gallery" <# if (data.layout=='gallery' ){ #>checked<# } #> />
|
92 |
+
<label for="insta_layout-gallery"><?php esc_html_e('Gallery', 'insta-gallery'); ?></label>
|
93 |
+
<img src="<?php echo plugins_url('/assets/backend/img/gallery.png', QLIGG_PLUGIN_FILE); ?>" />
|
94 |
+
</li>
|
95 |
+
<li class="media-modal-image <# if ( data.layout == 'carousel') {#>active<# } #>">
|
96 |
<input type="radio" name="layout" value="carousel" <# if (data.layout== 'carousel'){ #>checked<# } #> />
|
97 |
<label for="insta_layout-carousel"><?php esc_html_e('Carousel', 'insta-gallery'); ?></label>
|
98 |
<img src="<?php echo plugins_url('/assets/backend/img/carousel.png', QLIGG_PLUGIN_FILE); ?>"/>
|
99 |
</li>
|
100 |
<li class="media-modal-image qligg-premium-field <# if ( data.layout == 'masonry') {#>active<#}#>">
|
101 |
+
<input type="radio" name="layout" value="masonry" <# if (data.layout=='masonry' ){ #>checked<# } #> />
|
102 |
+
<label for="insta_layout-masonry"><?php esc_html_e('Masonry', 'insta-gallery'); ?>
|
103 |
+
<span class="description hidden"><small><?php esc_html_e('(This is a premium feature)', 'insta-gallery'); ?></small></span>
|
104 |
+
</label>
|
105 |
+
<img src="<?php echo plugins_url('/assets/backend/img/masonry.png', QLIGG_PLUGIN_FILE); ?>" />
|
106 |
+
</li>
|
107 |
+
<li class="media-modal-image qligg-premium-field <# if ( data.layout == 'highlight') {#>active<#}#>">
|
108 |
+
<input type="radio" id="insta_layout-highlight" name="layout" value="highlight" <# if (data.layout=='highlight' ){ #>checked<# } #> />
|
109 |
+
<label for="insta_layout-highlight"><?php esc_html_e('Highlight', 'insta-gallery'); ?>
|
110 |
+
<span class="description hidden"><small><?php esc_html_e('(This is a premium feature)', 'insta-gallery'); ?></small></span>
|
111 |
+
</label>
|
112 |
+
<img src="<?php echo plugins_url('/assets/backend/img/highlight.png', QLIGG_PLUGIN_FILE); ?>" />
|
113 |
+
</li>
|
114 |
+
</ul>
|
115 |
+
</div>
|
116 |
+
</div>
|
117 |
|
118 |
+
<div class="options_group">
|
119 |
+
<p class="form-field">
|
120 |
+
<label><?php esc_html_e('Limit', 'insta-gallery'); ?></label>
|
121 |
+
<input name="limit" type="number" min="1" max="50" value="{{data.limit}}" />
|
122 |
+
<span class="description"><small><?php esc_html_e('Number of images to display', 'insta-gallery'); ?></small></span>
|
123 |
+
</p>
|
124 |
+
</div>
|
125 |
|
126 |
+
<div class="options_group <# if(!_.contains(['gallery', 'masonry', 'highlight'], data.layout)) { #>hidden<# } #>">
|
127 |
+
<p class="form-field">
|
128 |
+
<label><?php esc_html_e('Columns', 'insta-gallery'); ?></label>
|
129 |
+
<input name="columns" type="number" min="1" max="20" value="{{data.columns}}" />
|
130 |
+
<span class="description"><small><?php esc_html_e('Number of images in a row', 'insta-gallery'); ?></small></span>
|
131 |
+
</p>
|
132 |
+
</div>
|
133 |
|
134 |
+
<div class="options_group qligg-premium-field <# if(!_.contains(['highlight', 'masonry'], data.layout)) { #>hidden<# } #>">
|
135 |
+
<p class="form-field">
|
136 |
+
<label><?php esc_html_e('Highlight by tag', 'insta-gallery'); ?></label>
|
137 |
+
<textarea name="highlight[tag]" placeholder="tag1, tag2, tag3">{{data.highlight.tag}}</textarea>
|
138 |
+
<span class="description"><small><?php esc_html_e('Highlight feeds items with this tags', 'insta-gallery'); ?></small></span>
|
139 |
+
<span class="description hidden"><small><?php esc_html_e('(This is a premium feature)', 'insta-gallery'); ?></small></span>
|
140 |
+
</p>
|
141 |
+
<p class="form-field">
|
142 |
+
<label><?php esc_html_e('Highlight by id', 'insta-gallery'); ?></label>
|
143 |
+
<textarea name="highlight[id]" placeholder="101010110101010">{{data.highlight.id}}</textarea>
|
144 |
+
<span class="description"><small><?php esc_html_e('Highlight feeds items with this ids', 'insta-gallery'); ?></small></span>
|
145 |
+
<span class="description hidden"><small><?php esc_html_e('(This is a premium feature)', 'insta-gallery'); ?></small></span>
|
146 |
+
</p>
|
147 |
+
<p class="form-field">
|
148 |
+
<label><?php esc_html_e('Highlight by position', 'insta-gallery'); ?></label>
|
149 |
+
<textarea name="highlight[position]" placeholder="1, 5, 7">{{data.highlight.position}}</textarea>
|
150 |
+
<span class="description"><small><?php esc_html_e('Highlight feeds items in this positions', 'insta-gallery'); ?></small></span>
|
151 |
+
<span class="description hidden"><small><?php esc_html_e('(This is a premium feature)', 'insta-gallery'); ?></small></span>
|
152 |
+
</p>
|
153 |
+
</div>
|
154 |
|
155 |
</div>
|
insta-gallery.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Social Feed Gallery
|
5 |
* Plugin URI: https://quadlayers.com/portfolio/instagram-feed-gallery/
|
6 |
* Description: Display beautiful and responsive galleries on your website from your Instagram feed account.
|
7 |
-
* Version: 2.9.
|
8 |
* Author: QuadLayers
|
9 |
* Author URI: https://quadlayers.com
|
10 |
* License: GPLv3
|
@@ -19,7 +19,7 @@ if (!defined('QLIGG_PLUGIN_NAME')) {
|
|
19 |
define('QLIGG_PLUGIN_NAME', 'Social Feed Gallery');
|
20 |
}
|
21 |
if (!defined('QLIGG_PLUGIN_VERSION')) {
|
22 |
-
define('QLIGG_PLUGIN_VERSION', '2.9.
|
23 |
}
|
24 |
if (!defined('QLIGG_PLUGIN_FILE')) {
|
25 |
define('QLIGG_PLUGIN_FILE', __FILE__);
|
4 |
* Plugin Name: Social Feed Gallery
|
5 |
* Plugin URI: https://quadlayers.com/portfolio/instagram-feed-gallery/
|
6 |
* Description: Display beautiful and responsive galleries on your website from your Instagram feed account.
|
7 |
+
* Version: 2.9.4
|
8 |
* Author: QuadLayers
|
9 |
* Author URI: https://quadlayers.com
|
10 |
* License: GPLv3
|
19 |
define('QLIGG_PLUGIN_NAME', 'Social Feed Gallery');
|
20 |
}
|
21 |
if (!defined('QLIGG_PLUGIN_VERSION')) {
|
22 |
+
define('QLIGG_PLUGIN_VERSION', '2.9.4');
|
23 |
}
|
24 |
if (!defined('QLIGG_PLUGIN_FILE')) {
|
25 |
define('QLIGG_PLUGIN_FILE', __FILE__);
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://quadlayers.com/portfolio/instagram-gallery/
|
|
4 |
Tags: Instagram, Instagram feed, Instagram gallery, Instagram photos, Instagram widget, Instagram pictures
|
5 |
Requires at least: 3.4
|
6 |
Tested up to: 5.4.2
|
7 |
-
Stable tag: 2.9.
|
8 |
License: GPLv3
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -105,6 +105,10 @@ There may be some other plugins(like: fancybox, elementor) which also uses image
|
|
105 |
|
106 |
== Changelog ==
|
107 |
|
|
|
|
|
|
|
|
|
108 |
= 2.9.3 =
|
109 |
* Fix. premium compatibility
|
110 |
|
4 |
Tags: Instagram, Instagram feed, Instagram gallery, Instagram photos, Instagram widget, Instagram pictures
|
5 |
Requires at least: 3.4
|
6 |
Tested up to: 5.4.2
|
7 |
+
Stable tag: 2.9.4
|
8 |
License: GPLv3
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
105 |
|
106 |
== Changelog ==
|
107 |
|
108 |
+
= 2.9.4 =
|
109 |
+
* Fix. premium compatibility
|
110 |
+
* New. Instagram tag feed order by
|
111 |
+
|
112 |
= 2.9.3 =
|
113 |
* Fix. premium compatibility
|
114 |
|