Version Description
- Compatibility with the new Instagram API's: Basic Display API and Graph API
Download this release
Release Info
Developer | designemotions |
Plugin | Enjoy Instagram feed on website with WordPress Widget and Shortcode |
Version | 5.0 |
Comparing to | |
See all releases |
Code changes from version 4.0.7 to 5.0
- assets/css/enjoyinstagram_settings.css +84 -71
- assets/images/enjoyinstagram.png +0 -0
- enjoyinstagram.php +26 -27
- includes/class.enjoyinstagram-activation.php +36 -34
- includes/class.enjoyinstagram-admin.php +377 -271
- includes/class.enjoyinstagram-api-connection.php +304 -218
- includes/class.enjoyinstagram-db.php +601 -0
- includes/class.enjoyinstagram-shortcodes.php +287 -265
- includes/class.enjoyinstagram.php +298 -0
- includes/functions.enjoyinstagram.php +133 -111
- readme.txt +55 -43
- templates/admin/enjoyinstagram-advanced-settings.php +97 -52
- templates/admin/enjoyinstagram-general-settings.php +54 -19
- templates/admin/settings.php +4 -4
- templates/shortcodes/carousel-widget.php +36 -34
- templates/shortcodes/carousel.php +1 -1
- templates/shortcodes/grid.php +44 -44
assets/css/enjoyinstagram_settings.css
CHANGED
@@ -1,91 +1,104 @@
|
|
1 |
.ei_block {
|
2 |
-
|
3 |
-
|
4 |
-
|
|
|
5 |
.ei_left_block {
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
10 |
.ei_hard_block {
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
14 |
.ei_twitter_block {
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
19 |
.ei_facebook_block {
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
23 |
#buy_me_a_coffee {
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
40 |
.pad_coffee {
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
47 |
.coffee_title {
|
48 |
-
|
49 |
-
|
50 |
|
51 |
|
52 |
#enjoy_user_profile {
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
63 |
|
64 |
.enjoy_user_profile {
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
border: 2px solid #e2e2e2;
|
70 |
-
|
71 |
-
|
72 |
}
|
73 |
-
|
74 |
.desc {
|
75 |
-
|
76 |
-
|
|
|
77 |
.highlighted {
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
85 |
.ei_fixed {
|
86 |
-
|
87 |
-
|
|
|
88 |
.ei_sel {
|
89 |
-
|
90 |
-
|
91 |
|
1 |
.ei_block {
|
2 |
+
display: table;
|
3 |
+
width: 100%;
|
4 |
+
}
|
5 |
+
|
6 |
.ei_left_block {
|
7 |
+
display: block;
|
8 |
+
float: left;
|
9 |
+
width: 280px;
|
10 |
+
}
|
11 |
+
|
12 |
.ei_hard_block {
|
13 |
+
display: block;
|
14 |
+
float: none;
|
15 |
+
}
|
16 |
+
|
17 |
.ei_twitter_block {
|
18 |
+
display: inline-block;
|
19 |
+
float: left;
|
20 |
+
margin-top: 6px;
|
21 |
+
}
|
22 |
+
|
23 |
.ei_facebook_block {
|
24 |
+
display: inline-block;
|
25 |
+
float: right;
|
26 |
+
}
|
27 |
+
|
28 |
#buy_me_a_coffee {
|
29 |
+
background-repeat: no-repeat;
|
30 |
+
border-left: 4px solid #7ad03a;
|
31 |
+
-webkit-box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .1);
|
32 |
+
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .1);
|
33 |
+
display: block;
|
34 |
+
float: right;
|
35 |
+
}
|
36 |
+
|
37 |
+
#premium_release {
|
38 |
+
padding: 10px;
|
39 |
+
border-left: 4px solid #FF7400;
|
40 |
+
background: #B6FFB4;
|
41 |
+
-webkit-box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .1);
|
42 |
+
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .1);
|
43 |
+
display: block;
|
44 |
+
margin: 10px auto;
|
45 |
+
}
|
46 |
+
|
47 |
.pad_coffee {
|
48 |
+
display: block;
|
49 |
+
float: none;
|
50 |
+
margin-left: 90px;
|
51 |
+
width: 235px;
|
52 |
+
padding: 8px;
|
53 |
+
}
|
54 |
+
|
55 |
.coffee_title {
|
56 |
+
font-size: 0.8;
|
57 |
+
}
|
58 |
|
59 |
|
60 |
#enjoy_user_profile {
|
61 |
+
width: 124px;
|
62 |
+
padding-top: 3px;
|
63 |
+
margin-right: 25px;
|
64 |
+
text-align: center;
|
65 |
+
display: inline-block;
|
66 |
+
float: left;
|
67 |
+
}
|
68 |
+
|
69 |
+
.ei_top {
|
70 |
+
margin-top: 30px;
|
71 |
+
}
|
72 |
|
73 |
.enjoy_user_profile {
|
74 |
+
border-radius: 50%;
|
75 |
+
width: 120px;
|
76 |
+
height: 120px;
|
77 |
+
margin: auto 0;
|
78 |
border: 2px solid #e2e2e2;
|
79 |
+
margin-bottom: 12px;
|
80 |
+
|
81 |
}
|
82 |
+
|
83 |
.desc {
|
84 |
+
padding: 15px;
|
85 |
+
}
|
86 |
+
|
87 |
.highlighted {
|
88 |
+
font-size: 1rem;
|
89 |
+
}
|
90 |
+
|
91 |
+
.ei_settings_float_block {
|
92 |
+
display: inline-block;
|
93 |
+
float: left;
|
94 |
+
margin-right: 1.5rem;
|
95 |
+
}
|
96 |
+
|
97 |
.ei_fixed {
|
98 |
+
width: 240px;
|
99 |
+
}
|
100 |
+
|
101 |
.ei_sel {
|
102 |
+
width: 75px;
|
103 |
+
}
|
104 |
|
assets/images/enjoyinstagram.png
CHANGED
Binary file
|
enjoyinstagram.php
CHANGED
@@ -1,42 +1,41 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
|
11 |
-
! defined( 'ENJOYINSTAGRAM_VERSION' ) && define( 'ENJOYINSTAGRAM_VERSION', '
|
12 |
! defined( 'ENJOYINSTAGRAM_FILE' ) && define( 'ENJOYINSTAGRAM_FILE', __FILE__ );
|
13 |
! defined( 'ENJOYINSTAGRAM_URL' ) && define( 'ENJOYINSTAGRAM_URL', plugin_dir_url( __FILE__ ) );
|
14 |
! defined( 'ENJOYINSTAGRAM_DIR' ) && define( 'ENJOYINSTAGRAM_DIR', plugin_dir_path( __FILE__ ) );
|
15 |
! defined( 'ENJOYINSTAGRAM_ASSETS_URL' ) && define( 'ENJOYINSTAGRAM_ASSETS_URL', ENJOYINSTAGRAM_URL . 'assets' );
|
16 |
-
! defined( 'ENJOYINSTAGRAM_TEMPLATE_PATH' ) && define( 'ENJOYINSTAGRAM_TEMPLATE_PATH',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
|
|
20 |
}
|
21 |
|
22 |
register_activation_hook( __FILE__, 'enjoyinstagram_require_activation_class' );
|
23 |
|
24 |
add_action( 'plugins_loaded', 'enjoyinstagram_init_plugin' );
|
25 |
-
function enjoyinstagram_init_plugin(){
|
26 |
-
|
27 |
-
load_plugin_textdomain( 'enjoy-instagram-instagram-responsive-images-gallery-and-carousel', false, dirname( plugin_basename( __FILE__ ) ). '/languages/' );
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
require_once( 'includes/class.enjoyinstagram-api-connection.php' );
|
32 |
-
require_once( 'includes/class.enjoyinstagram-shortcodes.php' );
|
33 |
-
// widgets
|
34 |
-
require_once( 'includes/widgets/widgets.php' );
|
35 |
-
require_once( 'includes/widgets/widgets_grid.php' );
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
require_once( 'includes/class.enjoyinstagram-admin.php' );
|
41 |
-
}
|
42 |
}
|
1 |
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Enjoy Plugin for Instagram
|
4 |
+
Description: Instagram Responsive Images Gallery and Carousel, works with Shortcodes and Widgets.
|
5 |
+
Version: 5.0.0
|
6 |
+
Author: Mediabeta Srl
|
7 |
+
Text Domain: enjoy-instagram-instagram-responsive-images-gallery-and-carousel
|
8 |
+
Author URI: http://www.mediabeta.com/team/
|
9 |
+
*/
|
10 |
|
11 |
+
! defined( 'ENJOYINSTAGRAM_VERSION' ) && define( 'ENJOYINSTAGRAM_VERSION', '5.0.0' );
|
12 |
! defined( 'ENJOYINSTAGRAM_FILE' ) && define( 'ENJOYINSTAGRAM_FILE', __FILE__ );
|
13 |
! defined( 'ENJOYINSTAGRAM_URL' ) && define( 'ENJOYINSTAGRAM_URL', plugin_dir_url( __FILE__ ) );
|
14 |
! defined( 'ENJOYINSTAGRAM_DIR' ) && define( 'ENJOYINSTAGRAM_DIR', plugin_dir_path( __FILE__ ) );
|
15 |
! defined( 'ENJOYINSTAGRAM_ASSETS_URL' ) && define( 'ENJOYINSTAGRAM_ASSETS_URL', ENJOYINSTAGRAM_URL . 'assets' );
|
16 |
+
! defined( 'ENJOYINSTAGRAM_TEMPLATE_PATH' ) && define( 'ENJOYINSTAGRAM_TEMPLATE_PATH',
|
17 |
+
ENJOYINSTAGRAM_DIR . 'templates' );
|
18 |
+
! defined( 'ENJOYINSTAGRAM_FB_APP_ID' ) && define( 'ENJOYINSTAGRAM_FB_APP_ID', '773612959700549' );
|
19 |
+
! defined( 'ENJOYINSTAGRAM_APP_ID' ) && define( 'ENJOYINSTAGRAM_APP_ID', '1367115243477960' );
|
20 |
+
! defined( 'ENJOYINSTAGRAM_GRAPH_API_REDIRECT' ) && define( 'ENJOYINSTAGRAM_GRAPH_API_REDIRECT',
|
21 |
+
'https://www.mediabetaprojects.com/enjoy-instagram-api/graph-api-redirect.php' );
|
22 |
+
! defined( 'ENJOYINSTAGRAM_BASIC_DISPLAY_API_REDIRECT' ) && define( 'ENJOYINSTAGRAM_BASIC_DISPLAY_API_REDIRECT',
|
23 |
+
'https://www.mediabetaprojects.com/enjoy-instagram-api/basic-display-redirect.php' );
|
24 |
|
25 |
+
|
26 |
+
function enjoyinstagram_require_activation_class() {
|
27 |
+
require_once( 'includes/class.enjoyinstagram-activation.php' );
|
28 |
}
|
29 |
|
30 |
register_activation_hook( __FILE__, 'enjoyinstagram_require_activation_class' );
|
31 |
|
32 |
add_action( 'plugins_loaded', 'enjoyinstagram_init_plugin' );
|
33 |
+
function enjoyinstagram_init_plugin() {
|
|
|
|
|
34 |
|
35 |
+
load_plugin_textdomain( 'enjoy-instagram-instagram-responsive-images-gallery-and-carousel', false,
|
36 |
+
dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
+
require_once( 'includes/functions.enjoyinstagram.php' );
|
39 |
+
require_once( 'includes/class.enjoyinstagram.php' );
|
40 |
+
EnjoyInstagram();
|
|
|
|
|
41 |
}
|
includes/class.enjoyinstagram-activation.php
CHANGED
@@ -3,44 +3,46 @@
|
|
3 |
* This class handles activation actions
|
4 |
*/
|
5 |
|
6 |
-
if( ! defined( 'ABSPATH' ) ) {
|
7 |
-
|
8 |
}
|
9 |
|
10 |
final class EnjoyInstagram_Activation {
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
44 |
}
|
45 |
|
46 |
new EnjoyInstagram_Activation();
|
3 |
* This class handles activation actions
|
4 |
*/
|
5 |
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // exit if call directly
|
8 |
}
|
9 |
|
10 |
final class EnjoyInstagram_Activation {
|
11 |
|
12 |
+
/**
|
13 |
+
* Construct
|
14 |
+
*
|
15 |
+
* @return void
|
16 |
+
*/
|
17 |
+
public function __construct() {
|
18 |
+
$this->add_default_settings();
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Add default plugin settings
|
23 |
+
*
|
24 |
+
* @return void
|
25 |
+
* @since 9.0.0
|
26 |
+
*/
|
27 |
+
public function add_default_settings() {
|
28 |
+
|
29 |
+
delete_option( 'enjoyinstagram_sync_times' );
|
30 |
+
|
31 |
+
$plugin_options = array();
|
32 |
+
if ( file_exists( ENJOYINSTAGRAM_DIR . 'plugin-options/options.php' ) ) {
|
33 |
+
$plugin_options = include( ENJOYINSTAGRAM_DIR . 'plugin-options/options.php' );
|
34 |
+
}
|
35 |
+
|
36 |
+
if ( empty( $plugin_options ) ) {
|
37 |
+
return;
|
38 |
+
}
|
39 |
+
|
40 |
+
foreach ( $plugin_options as $options ) {
|
41 |
+
foreach ( $options as $option_id => $default_value ) {
|
42 |
+
add_option( $option_id, $default_value );
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
}
|
47 |
|
48 |
new EnjoyInstagram_Activation();
|
includes/class.enjoyinstagram-admin.php
CHANGED
@@ -3,280 +3,386 @@
|
|
3 |
* This class handles all admin actions
|
4 |
*/
|
5 |
|
6 |
-
if( ! defined( 'ABSPATH' ) ) {
|
7 |
-
|
8 |
}
|
9 |
|
10 |
class EnjoyInstagram_Admin {
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
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 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
}
|
281 |
|
282 |
/**
|
@@ -286,7 +392,7 @@ class EnjoyInstagram_Admin {
|
|
286 |
* @since 9.0.0
|
287 |
*/
|
288 |
function EnjoyInstagram_Admin() {
|
289 |
-
|
290 |
}
|
291 |
|
292 |
EnjoyInstagram_Admin();
|
3 |
* This class handles all admin actions
|
4 |
*/
|
5 |
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // exit if call directly
|
8 |
}
|
9 |
|
10 |
class EnjoyInstagram_Admin {
|
11 |
|
12 |
+
/**
|
13 |
+
* Single plugin instance
|
14 |
+
* @since 9.0.0
|
15 |
+
* @var \EnjoyInstagram_Admin
|
16 |
+
*/
|
17 |
+
protected static $instance;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Plugin options page name
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
protected $_options_page = 'enjoyinstagram_plugin_options';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Plugin options page name
|
27 |
+
* @var array
|
28 |
+
*/
|
29 |
+
protected $_tabs = [];
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Plugin options page name
|
33 |
+
* @var array
|
34 |
+
*/
|
35 |
+
protected $_plugin_options = [];
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Returns single instance of the class
|
39 |
+
*
|
40 |
+
* @return \EnjoyInstagram_Admin
|
41 |
+
* @since 1.0.0
|
42 |
+
*/
|
43 |
+
public static function get_instance() {
|
44 |
+
if ( is_null( self::$instance ) ) {
|
45 |
+
self::$instance = new self();
|
46 |
+
}
|
47 |
+
|
48 |
+
return self::$instance;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Construct
|
53 |
+
*
|
54 |
+
* @return void
|
55 |
+
*/
|
56 |
+
private function __construct() {
|
57 |
+
$this->init();
|
58 |
+
add_action( 'admin_menu', array( $this, 'add_admin_menus' ) );
|
59 |
+
add_action( 'admin_notices', array( $this, 'print_notices' ) );
|
60 |
+
// register default options group
|
61 |
+
add_action( 'admin_init', array( $this, 'register_settings' ) );
|
62 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles_scripts' ) );
|
63 |
+
add_action( 'admin_print_footer_scripts', array( $this, 'admin_footer_scripts' ), PHP_INT_MAX );
|
64 |
+
add_filter( 'plugin_action_links_' . plugin_basename( ENJOYINSTAGRAM_DIR . '/' . basename( ENJOYINSTAGRAM_FILE ) ),
|
65 |
+
array( $this, 'settings_link' ) );
|
66 |
+
// add/remove user
|
67 |
+
add_action( 'admin_init', array( $this, 'add_user' ), 1 );
|
68 |
+
add_action( 'admin_init', array( $this, 'remove_user' ), 1 );
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Check if current page is a plugin admin page
|
73 |
+
*
|
74 |
+
* @return boolean
|
75 |
+
* @since 11.0.0
|
76 |
+
*/
|
77 |
+
public function is_admin_page() {
|
78 |
+
return isset( $_GET['page'] ) && $_GET['page'] == $this->_options_page;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Print notices in plugin admin pages
|
83 |
+
*
|
84 |
+
* @return void
|
85 |
+
* @since 11.0.0
|
86 |
+
*/
|
87 |
+
public function print_notices() {
|
88 |
+
if ( ! $this->is_admin_page() ) {
|
89 |
+
return;
|
90 |
+
}
|
91 |
+
|
92 |
+
$notices = enjoyinstagram_get_notices();
|
93 |
+
|
94 |
+
if ( ! $notices ) {
|
95 |
+
return;
|
96 |
+
}
|
97 |
+
|
98 |
+
foreach ( $notices as $notice ) {
|
99 |
+
?>
|
100 |
+
<div class="updated settings-error <?php echo $notice['type'] ?> is-dismissible">
|
101 |
+
<p><?php echo $notice['message'] ?></p>
|
102 |
+
</div>
|
103 |
+
<?php
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Init admin class variables
|
109 |
+
*
|
110 |
+
* @return void
|
111 |
+
* @since 9.0.0
|
112 |
+
*/
|
113 |
+
protected function init() {
|
114 |
+
// init tabs
|
115 |
+
$this->_tabs = apply_filters( 'enjoyinstagram_plugin_admin_tabs', array(
|
116 |
+
'enjoyinstagram_general_settings' => __( 'Profile',
|
117 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ),
|
118 |
+
'enjoyinstagram_advanced_settings' => __( 'Settings',
|
119 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' )
|
120 |
+
) );
|
121 |
+
|
122 |
+
if ( file_exists( ENJOYINSTAGRAM_DIR . 'plugin-options/options.php' ) ) {
|
123 |
+
$this->_plugin_options = include( ENJOYINSTAGRAM_DIR . 'plugin-options/options.php' );
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Build an admin url
|
129 |
+
*
|
130 |
+
* @param string $tab
|
131 |
+
* @param array $params
|
132 |
+
*
|
133 |
+
* @return string
|
134 |
+
* @since 4.0.0
|
135 |
+
*/
|
136 |
+
public function build_admin_url( $tab, $params = array() ) {
|
137 |
+
$params_string = '';
|
138 |
+
foreach ( $params as $key => $value ) {
|
139 |
+
$params_string .= '&' . $key . '=' . $value;
|
140 |
+
}
|
141 |
+
|
142 |
+
return admin_url( "options-general.php?page={$this->_options_page}&tab={$tab}{$params_string}" );
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Enqueue plugin styles and scripts
|
147 |
+
*
|
148 |
+
* @return void
|
149 |
+
* @since 9.0.0
|
150 |
+
*/
|
151 |
+
public function admin_styles_scripts() {
|
152 |
+
global $wp_scripts;
|
153 |
+
|
154 |
+
wp_register_style( 'enjoyinstagram_settings', ENJOYINSTAGRAM_ASSETS_URL . '/css/enjoyinstagram_settings.css',
|
155 |
+
array(), ENJOYINSTAGRAM_VERSION );
|
156 |
+
|
157 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] == $this->_options_page ) {
|
158 |
+
wp_enqueue_style( 'enjoyinstagram_settings' );
|
159 |
+
wp_enqueue_script( "jquery-ui-core" );
|
160 |
+
wp_enqueue_script( 'jquery-ui-tooltip' );
|
161 |
+
wp_enqueue_style( 'plugin_name-admin-ui-css',
|
162 |
+
'//ajax.googleapis.com/ajax/libs/jqueryui/' . $wp_scripts->registered['jquery-ui-core']->ver . '/themes/smoothness/jquery-ui.css',
|
163 |
+
false,
|
164 |
+
ENJOYINSTAGRAM_VERSION,
|
165 |
+
false );
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Enqueue admin footer scripts
|
171 |
+
*
|
172 |
+
* @since 5.0.0
|
173 |
+
*/
|
174 |
+
public function admin_footer_scripts() {
|
175 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] == $this->_options_page ) {
|
176 |
+
?>
|
177 |
+
<script type="text/javascript">
|
178 |
+
jQuery(function () {
|
179 |
+
jQuery(".enjoy-instagram-help").tooltip({
|
180 |
+
content: function () {
|
181 |
+
return jQuery(this).prop('title');
|
182 |
+
}
|
183 |
+
});
|
184 |
+
})
|
185 |
+
</script>
|
186 |
+
<?php
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Add admin menu under Settings
|
192 |
+
*
|
193 |
+
* @return void
|
194 |
+
* @since 9.0.0
|
195 |
+
*/
|
196 |
+
public function add_admin_menus() {
|
197 |
+
add_options_page(
|
198 |
+
__( 'Enjoy Plugin for Instagram', 'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ),
|
199 |
+
__( 'Enjoy Plugin for Instagram', 'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ),
|
200 |
+
'manage_options',
|
201 |
+
$this->_options_page,
|
202 |
+
array( $this, 'output_options_page' ) );
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Add plugin settings link
|
207 |
+
*
|
208 |
+
* @param string $links
|
209 |
+
*
|
210 |
+
* @return string
|
211 |
+
* @since 9.0.0
|
212 |
+
*/
|
213 |
+
public function settings_link( $links ) {
|
214 |
+
$links[] = '<a href="options-general.php?page=' . $this->_options_page . '">' . __( 'Settings',
|
215 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ) . '</a>';
|
216 |
+
$links[] = '<a href="widgets.php">' . __( 'Widgets',
|
217 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ) . '</a>';
|
218 |
+
$links[] = '<a href="http://www.mediabeta.com/enjoy-instagram/">' . __( 'Premium Version',
|
219 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ) . '</a>';
|
220 |
+
|
221 |
+
return $links;
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Register settings
|
226 |
+
*
|
227 |
+
* @return void
|
228 |
+
* @since 9.0.0
|
229 |
+
*/
|
230 |
+
public function register_settings() {
|
231 |
+
if ( empty( $this->_plugin_options ) ) {
|
232 |
+
return;
|
233 |
+
}
|
234 |
+
|
235 |
+
foreach ( $this->_plugin_options as $group => $options ) {
|
236 |
+
foreach ( $options as $option_id => $default ) {
|
237 |
+
register_setting( $group, $option_id );
|
238 |
+
}
|
239 |
+
}
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Get plugin admin tabs
|
244 |
+
*
|
245 |
+
* @sine 9.0.0
|
246 |
+
* @return array
|
247 |
+
*/
|
248 |
+
public function get_tabs() {
|
249 |
+
return $this->_tabs;
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Get current active tab or return the first one
|
254 |
+
*
|
255 |
+
* @return string
|
256 |
+
* @since 9.0.0
|
257 |
+
*/
|
258 |
+
public function get_active_tab() {
|
259 |
+
if ( ! is_array( $this->_tabs ) ) {
|
260 |
+
return '';
|
261 |
+
}
|
262 |
+
|
263 |
+
$c = isset( $_GET['tab'] ) ? $_GET['tab'] : '';
|
264 |
+
reset( $this->_tabs );
|
265 |
+
|
266 |
+
return isset( $this->_tabs[ $c ] ) ? $c : key( $this->_tabs );
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Get admin tab url
|
271 |
+
*
|
272 |
+
* @param string $tab
|
273 |
+
*
|
274 |
+
* @return string
|
275 |
+
* @since 9.0.0
|
276 |
+
*/
|
277 |
+
public function get_tab_url( $tab ) {
|
278 |
+
return add_query_arg( array( 'page' => $this->_options_page, 'tab' => $tab ),
|
279 |
+
admin_url( 'options-general.php' ) );
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* Output plugin options page
|
284 |
+
*
|
285 |
+
* @return void
|
286 |
+
* @since 9.0.0
|
287 |
+
*/
|
288 |
+
public function output_options_page() {
|
289 |
+
$tabs = $this->get_tabs();
|
290 |
+
$active_tab = $this->get_active_tab();
|
291 |
+
|
292 |
+
include( ENJOYINSTAGRAM_TEMPLATE_PATH . '/admin/settings.php' );
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Manage Instagram response and add a new user
|
297 |
+
*
|
298 |
+
* @return void
|
299 |
+
* @since 4.0.0
|
300 |
+
*/
|
301 |
+
public function add_user() {
|
302 |
+
if ( ( isset( $_GET['page'] ) && $_GET['page'] != $this->_options_page ) || ! isset( $_GET['access_token'] ) || ! isset( $_GET['api'] ) ) {
|
303 |
+
return;
|
304 |
+
}
|
305 |
+
|
306 |
+
$is_business = $_GET['api'] === 'graph';
|
307 |
+
$access_token = sanitize_text_field( $_GET['access_token'] );
|
308 |
+
$data = EnjoyInstagram_Api_Connection()->get_user_profile( $access_token, $is_business );
|
309 |
+
|
310 |
+
if ( $data === false ) {
|
311 |
+
$message = EnjoyInstagram_Api_Connection()->last_error;
|
312 |
+
enjoyinstagram_add_notice( $message, 'error' );
|
313 |
+
} else {
|
314 |
+
$data['access_token'] = $access_token;
|
315 |
+
EnjoyInstagram()->add_user( $data['username'], $data );
|
316 |
+
enjoyinstagram_add_notice(
|
317 |
+
sprintf( __( 'User %s successfully added', 'enjoyinstagram' ), $data['username'] ),
|
318 |
+
'notice'
|
319 |
+
);
|
320 |
+
}
|
321 |
+
|
322 |
+
// redirect to main settings page
|
323 |
+
wp_redirect( $this->build_admin_url( 'enjoyinstagram_general_settings' ) );
|
324 |
+
exit;
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* Remove and user from plugin
|
329 |
+
*
|
330 |
+
* @return void
|
331 |
+
* @since 4.0.0
|
332 |
+
*/
|
333 |
+
public function remove_user() {
|
334 |
+
|
335 |
+
if ( ! isset( $_REQUEST['action'] ) || $_REQUEST['action'] != 'enjoyinstagram_remove_user' ) {
|
336 |
+
return;
|
337 |
+
}
|
338 |
+
|
339 |
+
update_option( 'enjoy_instagram_options', array() );
|
340 |
+
delete_option( 'enjoyinstagram_sync_times' );
|
341 |
+
EnjoyInstagram_DB()->clear_all();
|
342 |
+
|
343 |
+
// redirect to main settings page
|
344 |
+
wp_redirect( $this->build_admin_url( 'enjoyinstagram_general_settings' ) );
|
345 |
+
exit;
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Get Instagram login url
|
350 |
+
*
|
351 |
+
* @return string
|
352 |
+
* @author Francesco Licandro
|
353 |
+
* @since 9.0.0
|
354 |
+
*/
|
355 |
+
public function get_instagram_login_url() {
|
356 |
+
$return_url = admin_url( "options-general.php?page={$this->_options_page}" );
|
357 |
+
|
358 |
+
return add_query_arg( array(
|
359 |
+
'app_id' => ENJOYINSTAGRAM_APP_ID,
|
360 |
+
'redirect_uri' => ENJOYINSTAGRAM_BASIC_DISPLAY_API_REDIRECT,
|
361 |
+
'response_type' => 'code',
|
362 |
+
'scope' => 'user_profile,user_media',
|
363 |
+
'state' => base64_encode( $return_url )
|
364 |
+
), 'https://api.instagram.com/oauth/authorize' );
|
365 |
+
}
|
366 |
+
|
367 |
+
/**
|
368 |
+
* Create url to connect with FB
|
369 |
+
*
|
370 |
+
* @return string Connection url
|
371 |
+
*/
|
372 |
+
public function get_facebook_connect_url() {
|
373 |
+
$admin_url = admin_url( 'options-general.php?page=' . $this->_options_page );
|
374 |
+
|
375 |
+
$auth_url = add_query_arg( array(
|
376 |
+
'response_type' => 'token',
|
377 |
+
'client_id' => ENJOYINSTAGRAM_FB_APP_ID,
|
378 |
+
'redirect_uri' => ENJOYINSTAGRAM_GRAPH_API_REDIRECT,
|
379 |
+
'scope' => 'manage_pages,instagram_basic',
|
380 |
+
), 'https://www.facebook.com/dialog/oauth' );
|
381 |
+
|
382 |
+
$auth_url .= '&state=' . base64_encode( $admin_url );
|
383 |
+
|
384 |
+
return $auth_url;
|
385 |
+
}
|
386 |
}
|
387 |
|
388 |
/**
|
392 |
* @since 9.0.0
|
393 |
*/
|
394 |
function EnjoyInstagram_Admin() {
|
395 |
+
return EnjoyInstagram_Admin::get_instance();
|
396 |
}
|
397 |
|
398 |
EnjoyInstagram_Admin();
|
includes/class.enjoyinstagram-api-connection.php
CHANGED
@@ -1,234 +1,320 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* This class handles
|
4 |
*/
|
5 |
|
6 |
-
if( ! defined( 'ABSPATH' ) ) {
|
7 |
-
|
8 |
}
|
9 |
|
10 |
class EnjoyInstagram_Api_Connection {
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
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 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
}
|
225 |
|
226 |
/**
|
227 |
* Unique access to instance of EnjoyInstagram_Api_Connection class
|
228 |
*
|
229 |
-
* @return
|
230 |
* @since 9.0.0
|
231 |
*/
|
232 |
function EnjoyInstagram_Api_Connection() {
|
233 |
-
|
234 |
-
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* This class handles API connection
|
4 |
*/
|
5 |
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // exit if call directly
|
8 |
}
|
9 |
|
10 |
class EnjoyInstagram_Api_Connection {
|
11 |
|
12 |
+
/**
|
13 |
+
* Single plugin instance
|
14 |
+
* @since 9.0.0
|
15 |
+
* @var EnjoyInstagram_Api_Connection
|
16 |
+
*/
|
17 |
+
protected static $instance;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Last error during api calls
|
21 |
+
*
|
22 |
+
* @var string
|
23 |
+
*/
|
24 |
+
public $last_error = '';
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Returns single instance of the class
|
28 |
+
*
|
29 |
+
* @return EnjoyInstagram_Api_Connection
|
30 |
+
* @since 1.0.0
|
31 |
+
*/
|
32 |
+
public static function get_instance() {
|
33 |
+
if ( is_null( self::$instance ) ) {
|
34 |
+
self::$instance = new self();
|
35 |
+
}
|
36 |
+
|
37 |
+
return self::$instance;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Get user profile
|
42 |
+
*
|
43 |
+
* @param string $access_token
|
44 |
+
* @param bool $is_business_profile
|
45 |
+
*
|
46 |
+
* @return array|false
|
47 |
+
* @author Giulio Ganci
|
48 |
+
* @since 11.0.0
|
49 |
+
*/
|
50 |
+
public function get_user_profile( $access_token, $is_business_profile ) {
|
51 |
+
|
52 |
+
$segment = 'me';
|
53 |
+
$params['access_token'] = $access_token;
|
54 |
+
$meta = [];
|
55 |
+
|
56 |
+
if ( $is_business_profile ) {
|
57 |
+
// check is the profile is a real business user
|
58 |
+
if ( false === ( $segment = $this->is_business( $access_token ) ) ) {
|
59 |
+
$this->last_error = __( 'There was an error with account connection; please, make sure to be a business account and try again!',
|
60 |
+
'enjoyinstagram' );
|
61 |
+
|
62 |
+
return false;
|
63 |
+
}
|
64 |
+
|
65 |
+
$params['fields'] = 'media_count,username,website,name,profile_picture_url,biography';
|
66 |
+
|
67 |
+
} else {
|
68 |
+
$params['fields'] = 'id,media_count,username,account_type';
|
69 |
+
}
|
70 |
+
|
71 |
+
$response = $this->_get_remote_data( $segment, $params, $is_business_profile );
|
72 |
+
|
73 |
+
if ( is_wp_error( $response ) ) {
|
74 |
+
return false;
|
75 |
+
}
|
76 |
+
|
77 |
+
if ( $is_business_profile ) {
|
78 |
+
$meta_params = array(
|
79 |
+
'fields' => 'followers_count,media_count,follows_count',
|
80 |
+
'access_token' => $access_token
|
81 |
+
);
|
82 |
+
$meta_response = $this->_get_remote_data( $response['id'], $meta_params, $is_business_profile );
|
83 |
+
|
84 |
+
if ( ! is_wp_error( $meta_response ) ) {
|
85 |
+
$meta = $meta_response;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
return array(
|
90 |
+
'business' => $is_business_profile,
|
91 |
+
'username' => enjoyinstagram_replace4byte( $response['username'] ),
|
92 |
+
'website' => $is_business_profile && isset( $response['website'] ) ? $response['website'] : '',
|
93 |
+
'profile_picture' => $is_business_profile && isset( $response['profile_picture_url'] ) ? $response['profile_picture_url'] : '',
|
94 |
+
'bio' => $is_business_profile && isset( $response['biography'] ) ? enjoyinstagram_replace4byte( $response['biography'] ) : '',
|
95 |
+
'full_name' => $is_business_profile && isset( $response['name'] ) ? enjoyinstagram_replace4byte( $response['name'] ) : '',
|
96 |
+
'id' => $response['id'],
|
97 |
+
'count' => $response['media_count'],
|
98 |
+
'meta' => $meta
|
99 |
+
);
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Returns the IG user media files
|
104 |
+
*
|
105 |
+
* @param $user
|
106 |
+
* @param int $limit
|
107 |
+
* @param string $next
|
108 |
+
*
|
109 |
+
* @return array
|
110 |
+
* @author Giulio Ganci
|
111 |
+
* @since 11.0.0
|
112 |
+
*/
|
113 |
+
public function get_user_media( $user, $limit = 20, $next = '' ) {
|
114 |
+
|
115 |
+
$limit = min( $limit, 200 );
|
116 |
+
$return = [ 'data' => [], 'next' => '' ];
|
117 |
+
|
118 |
+
if ( empty( $next ) ) {
|
119 |
+
$response = $this->_get_remote_data( "{$user['id']}/media", array(
|
120 |
+
'fields' => 'media_url,thumbnail_url,caption,id,media_type,timestamp,username,permalink,like_count',
|
121 |
+
'access_token' => $user['access_token'],
|
122 |
+
'limit' => $limit
|
123 |
+
), $user['business'] );
|
124 |
+
} else {
|
125 |
+
$response = $this->_get_remote_data( $next );
|
126 |
+
}
|
127 |
+
|
128 |
+
if ( is_wp_error( $response ) ) {
|
129 |
+
return $return;
|
130 |
+
}
|
131 |
+
|
132 |
+
$return['data'] = $this->map_media( $response['data'] );
|
133 |
+
|
134 |
+
if ( isset( $response['paging'] ) && isset( $response['paging']['next'] ) && ! empty( $response['paging']['next'] ) ) {
|
135 |
+
$return['next'] = $response['paging']['next'];
|
136 |
+
}
|
137 |
+
|
138 |
+
return $return;
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Fetch remote API data
|
143 |
+
*
|
144 |
+
* @param string $segment
|
145 |
+
* @param array $params
|
146 |
+
* @param bool $graph_api
|
147 |
+
*
|
148 |
+
* @return array|WP_Error
|
149 |
+
* @author Giulio Ganci
|
150 |
+
* @since 11.0.0
|
151 |
+
*/
|
152 |
+
private function _get_remote_data( $segment = '', $params = [], $graph_api = true ) {
|
153 |
+
|
154 |
+
if ( strpos( $segment, 'http' ) !== false ) {
|
155 |
+
$url = $segment;
|
156 |
+
} else {
|
157 |
+
$api_url = $graph_api ? 'https://graph.facebook.com/' : 'https://graph.instagram.com/';
|
158 |
+
$url = $api_url . $segment . '?' . http_build_query( $params );
|
159 |
+
}
|
160 |
+
|
161 |
+
$args = array(
|
162 |
+
'timeout' => 60,
|
163 |
+
'sslverify' => false
|
164 |
+
);
|
165 |
+
|
166 |
+
$this->last_error = '';
|
167 |
+
$response = wp_remote_get( $url, $args );
|
168 |
+
|
169 |
+
if ( ! is_wp_error( $response ) ) {
|
170 |
+
// certain ways of representing the html for double quotes causes errors so replaced here.
|
171 |
+
$response = json_decode( str_replace( '%22', '”', $response['body'] ), true );
|
172 |
+
|
173 |
+
if ( isset( $response['error'] ) ) {
|
174 |
+
$response = new WP_Error( $response['error']['code'], $response['error']['message'] );
|
175 |
+
}
|
176 |
+
}
|
177 |
+
|
178 |
+
if ( is_wp_error( $response ) ) {
|
179 |
+
$this->last_error = $response->get_error_message('http_request_failed');
|
180 |
+
}
|
181 |
+
|
182 |
+
return $response;
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Check if given access token is valid for a business account and return the business ID
|
187 |
+
*
|
188 |
+
* @param string $access_token
|
189 |
+
*
|
190 |
+
* @return boolean|string
|
191 |
+
* @since 11.0.0
|
192 |
+
*/
|
193 |
+
public function is_business( $access_token ) {
|
194 |
+
|
195 |
+
$data = $this->_get_remote_data( 'me/accounts', array( 'access_token' => $access_token ), true );
|
196 |
+
|
197 |
+
if ( is_wp_error( $data ) ) {
|
198 |
+
return false;
|
199 |
+
}
|
200 |
+
|
201 |
+
if ( empty( $data ) || empty( $data['data'] ) || ! is_array( $data['data'] ) ) {
|
202 |
+
return false;
|
203 |
+
}
|
204 |
+
|
205 |
+
$data = array_shift( $data['data'] );
|
206 |
+
$page_id = $data['id'];
|
207 |
+
|
208 |
+
$data = $this->_get_remote_data( $page_id,
|
209 |
+
array( 'fields' => 'instagram_business_account', 'access_token' => $access_token ), true );
|
210 |
+
|
211 |
+
if ( is_wp_error( $data ) ) {
|
212 |
+
return false;
|
213 |
+
}
|
214 |
+
|
215 |
+
if ( empty( $data ) || empty( $data['instagram_business_account'] ) || empty( $data['instagram_business_account']['id'] ) ) {
|
216 |
+
return false;
|
217 |
+
}
|
218 |
+
|
219 |
+
return sanitize_text_field( $data['instagram_business_account']['id'] );
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Search business hashtag
|
224 |
+
*
|
225 |
+
* Get first the hashtag ID
|
226 |
+
* GET graph.facebook.com/ig_hashtag_search?user_id=17841405309211844&q=bluebottle&access_token={access-token}
|
227 |
+
* then get top media
|
228 |
+
* GET graph.facebook.com/{hashtag-id}/top_media?user_id={user-id}&fields=id,media_type,comments_count,like_count&access_token={access-token}
|
229 |
+
*
|
230 |
+
* @param array $user
|
231 |
+
* @param string $hashtag
|
232 |
+
* @param int $limit
|
233 |
+
*
|
234 |
+
* @return array
|
235 |
+
* @since 11.0.0
|
236 |
+
*/
|
237 |
+
public function search_business_hashtag( $user, $hashtag, $limit = 20 ) {
|
238 |
+
|
239 |
+
$params = array( 'user_id' => $user['id'], 'access_token' => $user['access_token'], 'q' => $hashtag );
|
240 |
+
$hashtag_data = $this->_get_remote_data( 'ig_hashtag_search', $params, true );
|
241 |
+
|
242 |
+
if ( is_wp_error( $hashtag_data ) ) {
|
243 |
+
return array();
|
244 |
+
}
|
245 |
+
|
246 |
+
if ( empty( $hashtag_data['data'] ) ) {
|
247 |
+
return array();
|
248 |
+
}
|
249 |
+
|
250 |
+
$hashtag = array_shift( $hashtag_data['data'] );
|
251 |
+
$hashtag_id = intval( $hashtag['id'] );
|
252 |
+
$params = array(
|
253 |
+
'user_id' => $user['id'],
|
254 |
+
'access_token' => $user['access_token'],
|
255 |
+
'fields' => 'id,permalink,media_url,caption,like_count',
|
256 |
+
'limit' => $limit
|
257 |
+
|
258 |
+
);
|
259 |
+
$medias = $this->_get_remote_data( "{$hashtag_id}/top_media", $params, true );
|
260 |
+
|
261 |
+
if ( is_wp_error( $medias ) ) {
|
262 |
+
return array();
|
263 |
+
}
|
264 |
+
|
265 |
+
if ( empty( $medias['data'] ) ) {
|
266 |
+
return array();
|
267 |
+
}
|
268 |
+
|
269 |
+
$filtered_medias = [];
|
270 |
+
foreach ( $medias['data'] as $media ) {
|
271 |
+
if ( isset( $media['media_url'] ) && $media['media_url'] ) {
|
272 |
+
$filtered_medias[] = $media;
|
273 |
+
}
|
274 |
+
}
|
275 |
+
|
276 |
+
return $this->map_media( $filtered_medias );
|
277 |
+
}
|
278 |
+
|
279 |
+
/**
|
280 |
+
* Map instagram media in a custom format
|
281 |
+
*
|
282 |
+
* @param array $data
|
283 |
+
*
|
284 |
+
* @return array
|
285 |
+
* @since 11.0.0
|
286 |
+
*/
|
287 |
+
protected function map_media( $data ) {
|
288 |
+
|
289 |
+
$return = [];
|
290 |
+
|
291 |
+
foreach ( $data as $media ) {
|
292 |
+
|
293 |
+
$caption = isset( $media['caption'] ) ? sanitize_text_field( $media['caption'] ) : '';
|
294 |
+
|
295 |
+
$return[] = array(
|
296 |
+
'image_id' => trim( $media['id'] ),
|
297 |
+
'image_link' => $media['permalink'],
|
298 |
+
'image_url' => $media['media_url'],
|
299 |
+
'thumbnail_url' => isset( $media['thumbnail_url'] ) ? $media['thumbnail_url'] : $media['media_url'],
|
300 |
+
'user' => isset( $media['username'] ) ? enjoyinstagram_replace4byte($media['username']) : '',
|
301 |
+
'caption' => isset( $media['caption'] ) ? sanitize_text_field( enjoyinstagram_replace4byte($media['caption']) ) : '',
|
302 |
+
'likes' => isset( $media['like_count'] ) ? $media['like_count'] : 0,
|
303 |
+
'tags' => enjoyinstagram_extract_hashtags( $caption ),
|
304 |
+
'date' => isset( $media['timestamp'] ) ? strtotime( $media['timestamp'] ) : ''
|
305 |
+
);
|
306 |
+
}
|
307 |
+
|
308 |
+
return $return;
|
309 |
+
}
|
310 |
}
|
311 |
|
312 |
/**
|
313 |
* Unique access to instance of EnjoyInstagram_Api_Connection class
|
314 |
*
|
315 |
+
* @return EnjoyInstagram_Api_Connection
|
316 |
* @since 9.0.0
|
317 |
*/
|
318 |
function EnjoyInstagram_Api_Connection() {
|
319 |
+
return EnjoyInstagram_Api_Connection::get_instance();
|
320 |
+
}
|
includes/class.enjoyinstagram-db.php
ADDED
@@ -0,0 +1,601 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This class handles DB connection and other DB stuff
|
4 |
+
*/
|
5 |
+
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // exit if call directly
|
8 |
+
}
|
9 |
+
|
10 |
+
class EnjoyInstagram_DB {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Main table name
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
protected $main_table = 'enjoy_instagram_media';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Main table name
|
20 |
+
* @var string
|
21 |
+
*/
|
22 |
+
protected $hashtags_table = 'enjoy_instagram_hashtags';
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Main sync ajax action name
|
26 |
+
* @var string
|
27 |
+
*/
|
28 |
+
protected $import_ajax_action = 'enjoyinstagram_import_ajax';
|
29 |
+
|
30 |
+
/**
|
31 |
+
* DB version
|
32 |
+
* @var string
|
33 |
+
*/
|
34 |
+
protected $db_version = '1.0.2';
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Single plugin instance
|
38 |
+
* @since 9.0.0
|
39 |
+
* @var \EnjoyInstagram_DB
|
40 |
+
*/
|
41 |
+
protected static $instance;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Returns single instance of the class
|
45 |
+
*
|
46 |
+
* @return \EnjoyInstagram_DB
|
47 |
+
* @since 1.0.0
|
48 |
+
*/
|
49 |
+
public static function get_instance() {
|
50 |
+
if ( is_null( self::$instance ) ) {
|
51 |
+
self::$instance = new self();
|
52 |
+
}
|
53 |
+
|
54 |
+
return self::$instance;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Construct
|
59 |
+
*
|
60 |
+
* @return void
|
61 |
+
*/
|
62 |
+
public function __construct() {
|
63 |
+
$this->init();
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Init class variables
|
68 |
+
*
|
69 |
+
* @return void
|
70 |
+
* @since 9.1.0
|
71 |
+
*/
|
72 |
+
public function init() {
|
73 |
+
global $wpdb;
|
74 |
+
|
75 |
+
$this->main_table = $wpdb->prefix . $this->main_table;
|
76 |
+
$this->hashtags_table = $wpdb->prefix . $this->hashtags_table;
|
77 |
+
|
78 |
+
// add tables
|
79 |
+
$this->add_tables();
|
80 |
+
// import data from old tables
|
81 |
+
add_action( 'wp_ajax_' . $this->import_ajax_action, array( $this, 'import_media_ajax' ) );
|
82 |
+
add_action( 'wp_ajax_nopriv_' . $this->import_ajax_action, array( $this, 'import_media_ajax' ) );
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Add plugin tables
|
87 |
+
*
|
88 |
+
* @return void
|
89 |
+
* @since 9.0.0
|
90 |
+
*/
|
91 |
+
public function add_tables() {
|
92 |
+
|
93 |
+
$installedDB = get_option( 'enjoy_instagram_installed_db_version', '0' );
|
94 |
+
if ( version_compare( $installedDB, $this->db_version, '>=' ) ) {
|
95 |
+
return;
|
96 |
+
}
|
97 |
+
|
98 |
+
global $wpdb;
|
99 |
+
|
100 |
+
switch ( $installedDB ) {
|
101 |
+
case '1.0.0':
|
102 |
+
$wpdb->query( "ALTER TABLE {$this->main_table} ADD date bigint(20) DEFAULT 0 NOT NULL" );
|
103 |
+
delete_option( 'enjoyinstagram_sync_times' );
|
104 |
+
break;
|
105 |
+
default:
|
106 |
+
$sqls = array();
|
107 |
+
$charset_collate = $wpdb->get_charset_collate();
|
108 |
+
|
109 |
+
$sqls['enjoy_instagram_media'] = "CREATE TABLE IF NOT EXISTS $this->main_table (
|
110 |
+
id bigint(20) NOT NULL AUTO_INCREMENT,
|
111 |
+
image_id varchar(255) DEFAULT '' NOT NULL,
|
112 |
+
image_link varchar(255) DEFAULT '' NOT NULL,
|
113 |
+
image_url text DEFAULT '' NOT NULL,
|
114 |
+
user varchar(225) DEFAULT '' NOT NULL,
|
115 |
+
caption longtext DEFAULT '' NOT NULL,
|
116 |
+
likes mediumint(9) DEFAULT 0 NOT NULL,
|
117 |
+
moderate varchar(20) DEFAULT '' NOT NULL,
|
118 |
+
date bigint(20) DEFAULT 0 NOT NULL,
|
119 |
+
UNIQUE KEY id (id)
|
120 |
+
) $charset_collate;";
|
121 |
+
|
122 |
+
$sqls['enjoy_instagram_hashtags'] = "CREATE TABLE IF NOT EXISTS $this->hashtags_table (
|
123 |
+
id bigint(20) NOT NULL AUTO_INCREMENT,
|
124 |
+
image_id bigint(20) DEFAULT 0 NOT NULL,
|
125 |
+
hashtag varchar(255) DEFAULT '' NOT NULL,
|
126 |
+
moderate varchar(20) DEFAULT '' NOT NULL,
|
127 |
+
UNIQUE KEY id (id)
|
128 |
+
) $charset_collate;";
|
129 |
+
|
130 |
+
if ( ! function_exists( 'dbDelta' ) ) {
|
131 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
132 |
+
}
|
133 |
+
|
134 |
+
foreach ( $sqls as $sql ) {
|
135 |
+
dbDelta( $sql );
|
136 |
+
}
|
137 |
+
|
138 |
+
$this->do_action_for_update();
|
139 |
+
break;
|
140 |
+
}
|
141 |
+
|
142 |
+
update_option( 'enjoy_instagram_installed_db_version', $this->db_version );
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Build where clause for queries
|
147 |
+
*
|
148 |
+
* @param array $where
|
149 |
+
*
|
150 |
+
* @return string
|
151 |
+
* @since 9.0.0
|
152 |
+
* @author Francesco Licandro
|
153 |
+
*/
|
154 |
+
public static function build_where( $where ) {
|
155 |
+
$return = '1=1';
|
156 |
+
|
157 |
+
if ( empty( $where ) ) {
|
158 |
+
return $return;
|
159 |
+
}
|
160 |
+
|
161 |
+
foreach ( $where as $condition ) {
|
162 |
+
! isset( $condition['compare'] ) && $condition['compare'] = '=';
|
163 |
+
! isset( $condition['relation'] ) && $condition['relation'] = 'AND';
|
164 |
+
|
165 |
+
$value = $condition['value'];
|
166 |
+
if ( is_array( $value ) ) {
|
167 |
+
$value = implode( "','", $value );
|
168 |
+
$value = "('{$value}')";
|
169 |
+
} elseif ( is_string( $value ) ) {
|
170 |
+
$value = "'{$value}'";
|
171 |
+
}
|
172 |
+
|
173 |
+
$return .= " {$condition['relation']} {$condition['key']} {$condition['compare']} $value";
|
174 |
+
}
|
175 |
+
|
176 |
+
return $return;
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Get media approved
|
181 |
+
*
|
182 |
+
* @param array $where
|
183 |
+
*
|
184 |
+
* @return mixed
|
185 |
+
* @since 9.0.0
|
186 |
+
*/
|
187 |
+
public function get_media( $where = array() ) {
|
188 |
+
global $wpdb;
|
189 |
+
$where = self::build_where( $where );
|
190 |
+
|
191 |
+
return $wpdb->get_results( "SELECT * FROM {$this->main_table} WHERE {$where} ORDER BY date DESC", ARRAY_A );
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Get media approved
|
196 |
+
*
|
197 |
+
* @param array $where
|
198 |
+
*
|
199 |
+
* @return mixed
|
200 |
+
* @since 9.0.0
|
201 |
+
*/
|
202 |
+
public function get_media_by_hashtag( $where = array() ) {
|
203 |
+
global $wpdb;
|
204 |
+
$where = self::build_where( $where );
|
205 |
+
|
206 |
+
$ids = $wpdb->get_col( "SELECT DISTINCT image_id FROM {$this->hashtags_table} WHERE {$where}" );
|
207 |
+
|
208 |
+
if ( empty( $ids ) ) {
|
209 |
+
return array();
|
210 |
+
}
|
211 |
+
|
212 |
+
$ids = implode( ',', $ids );
|
213 |
+
|
214 |
+
return $wpdb->get_results( "SELECT * FROM {$this->main_table} WHERE id IN ({$ids}) ORDER BY date DESC",
|
215 |
+
ARRAY_A );
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Moderate an image
|
220 |
+
*
|
221 |
+
* @param string $type
|
222 |
+
* @param array $args
|
223 |
+
*
|
224 |
+
* @return boolean
|
225 |
+
* @author Francesco Licandro
|
226 |
+
* @since 9.0.0
|
227 |
+
*/
|
228 |
+
public function moderate_image( $type, $args ) {
|
229 |
+
global $wpdb;
|
230 |
+
|
231 |
+
/**
|
232 |
+
* @var string $moderate
|
233 |
+
* @var string $value
|
234 |
+
*/
|
235 |
+
extract( $args );
|
236 |
+
|
237 |
+
if ( empty( $media_id ) ) {
|
238 |
+
return false;
|
239 |
+
}
|
240 |
+
|
241 |
+
if ( $type == 'hashtag' ) {
|
242 |
+
$wpdb->query( "UPDATE {$this->hashtags_table} SET moderate = '{$moderate}' WHERE hashtag = '{$value}' AND image_id = {$media_id}" );
|
243 |
+
} else {
|
244 |
+
$wpdb->query( "UPDATE {$this->main_table} SET moderate = '{$moderate}' WHERE id = {$media_id}" );
|
245 |
+
}
|
246 |
+
|
247 |
+
return true;
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Get media for shortcode by user
|
252 |
+
*
|
253 |
+
* @param string $user
|
254 |
+
* @param array $hashtags
|
255 |
+
* @param boolean|string $moderate
|
256 |
+
* @param boolean|integer $limit
|
257 |
+
*
|
258 |
+
* @return array
|
259 |
+
* @author Francesco Licandro
|
260 |
+
* @since 9.0.0
|
261 |
+
*/
|
262 |
+
public function get_shortcode_media_user( $user, $hashtags = array(), $moderate = false, $limit = false ) {
|
263 |
+
global $wpdb;
|
264 |
+
|
265 |
+
( $limit === false ) && $limit = get_option( 'enjoyinstagram_images_captured', 20 );
|
266 |
+
|
267 |
+
$where = "user = '{$user}'";
|
268 |
+
$moderate !== false && $where .= " AND moderate = '{$moderate}'";
|
269 |
+
|
270 |
+
if ( ! empty( $hashtags ) ) {
|
271 |
+
$hashtags = implode( "','", $hashtags );
|
272 |
+
$hashtags = str_replace( '#', '', $hashtags ); // remove char #
|
273 |
+
$ids = $wpdb->get_col( "SELECT DISTINCT image_id FROM {$this->hashtags_table} WHERE hashtag IN ('{$hashtags}')" );
|
274 |
+
if ( empty( $ids ) ) {
|
275 |
+
return array();
|
276 |
+
}
|
277 |
+
|
278 |
+
$ids = implode( "','", $ids );
|
279 |
+
$where .= " AND id IN ('{$ids}')";
|
280 |
+
}
|
281 |
+
|
282 |
+
$result = $wpdb->get_results( "SELECT * FROM {$this->main_table} WHERE {$where} ORDER BY date DESC LIMIT {$limit}",
|
283 |
+
ARRAY_A );
|
284 |
+
|
285 |
+
return $result;
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Get images id by hashtags
|
290 |
+
*
|
291 |
+
* @param array $hashtags
|
292 |
+
* @param boolean $moderate
|
293 |
+
* @param int|bool $limit
|
294 |
+
*
|
295 |
+
* @return array
|
296 |
+
* @author Francesco Licandro
|
297 |
+
* @since 9.0.0
|
298 |
+
*/
|
299 |
+
public function get_shortcode_media_hashtag( $hashtags, $moderate = false, $limit = false ) {
|
300 |
+
global $wpdb;
|
301 |
+
|
302 |
+
( $limit === false ) && $limit = get_option( 'enjoyinstagram_images_captured', 20 );
|
303 |
+
|
304 |
+
if ( empty( $hashtags ) ) {
|
305 |
+
return array();
|
306 |
+
}
|
307 |
+
|
308 |
+
$hashtags = implode( "','", $hashtags );
|
309 |
+
$hashtags = str_replace( '#', '', $hashtags ); // remove char #
|
310 |
+
$where_moderate = ( $moderate !== false ) ? " AND moderate = '{$moderate}'" : '';
|
311 |
+
$ids = $wpdb->get_col( "SELECT DISTINCT image_id FROM {$this->hashtags_table} WHERE hashtag IN ('{$hashtags}') {$where_moderate}" );
|
312 |
+
if ( empty( $ids ) ) {
|
313 |
+
return array();
|
314 |
+
}
|
315 |
+
|
316 |
+
$ids = implode( "','", $ids );
|
317 |
+
$result = $wpdb->get_results( "SELECT * FROM {$this->main_table} WHERE id IN ('{$ids}') ORDER BY date DESC LIMIT {$limit}",
|
318 |
+
ARRAY_A );
|
319 |
+
|
320 |
+
// double check for url expired
|
321 |
+
/* foreach( $result as $key => $media ) {
|
322 |
+
if( ! $media->user ) {
|
323 |
+
$response = wp_remote_get( $media->image_url );
|
324 |
+
if( wp_remote_retrieve_response_code( $response ) == '403' ){
|
325 |
+
unset( $result[$key] );
|
326 |
+
$this->delete_media( $media->id );
|
327 |
+
}
|
328 |
+
}
|
329 |
+
}*/
|
330 |
+
|
331 |
+
return $result;
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Add in main table
|
336 |
+
*
|
337 |
+
* @param array $data
|
338 |
+
*
|
339 |
+
* @return boolean|integer
|
340 |
+
* @since 9.0.0
|
341 |
+
* @author Francesco Licandro
|
342 |
+
*/
|
343 |
+
public function add_in_main_table( $data ) {
|
344 |
+
global $wpdb;
|
345 |
+
|
346 |
+
if ( empty( $data['image_id'] ) ) {
|
347 |
+
return false;
|
348 |
+
}
|
349 |
+
|
350 |
+
$id = $wpdb->get_var( "SELECT id FROM {$this->main_table} WHERE image_id = '{$data['image_id']}'" );
|
351 |
+
$table_cols = array(
|
352 |
+
'image_id' => '%s',
|
353 |
+
'image_link' => '%s',
|
354 |
+
'image_url' => '%s',
|
355 |
+
'user' => '%s',
|
356 |
+
'caption' => '%s',
|
357 |
+
'likes' => '%d',
|
358 |
+
'moderate' => '%s',
|
359 |
+
'date' => '%d'
|
360 |
+
);
|
361 |
+
|
362 |
+
$insert = array_intersect_key( $data, $table_cols );
|
363 |
+
$format = array_merge( $insert, array_intersect_key( $table_cols, $data ) );
|
364 |
+
|
365 |
+
if ( empty( $id ) ) {
|
366 |
+
$wpdb->insert( $this->main_table, $insert, $format );
|
367 |
+
$id = $wpdb->insert_id;
|
368 |
+
} else { // update
|
369 |
+
$wpdb->update( $this->main_table, $insert, array( 'id' => $id ), $format, array( 'id' => '%d' ) );
|
370 |
+
}
|
371 |
+
|
372 |
+
return $id;
|
373 |
+
}
|
374 |
+
|
375 |
+
/**
|
376 |
+
* Delete a media
|
377 |
+
*
|
378 |
+
* @param string|integer $id
|
379 |
+
*
|
380 |
+
* @return void
|
381 |
+
* @since 10.0.1
|
382 |
+
*/
|
383 |
+
public function delete_media( $id ) {
|
384 |
+
global $wpdb;
|
385 |
+
|
386 |
+
$id = intval( $id );
|
387 |
+
|
388 |
+
$wpdb->query( "DELETE FROM {$this->main_table} WHERE id = {$id}" );
|
389 |
+
$wpdb->query( "DELETE FROM {$this->hashtags_table} WHERE image_id = {$id}" );
|
390 |
+
}
|
391 |
+
|
392 |
+
/**
|
393 |
+
* Delete media by user
|
394 |
+
*
|
395 |
+
* @param string $user_id
|
396 |
+
*
|
397 |
+
* @return void
|
398 |
+
* @since 11.0.0
|
399 |
+
*/
|
400 |
+
public function delete_media_by_user( $user_id ) {
|
401 |
+
global $wpdb;
|
402 |
+
|
403 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM {$this->main_table} WHERE user = %s", $user_id ) );
|
404 |
+
$wpdb->query( "DELETE FROM {$this->hashtags_table} WHERE image_id NOT IN ( SELECT id FROM {$this->main_table} )" );
|
405 |
+
}
|
406 |
+
|
407 |
+
/**
|
408 |
+
* Clean all media related data
|
409 |
+
*
|
410 |
+
* @return void
|
411 |
+
* @since 5.0.0
|
412 |
+
*/
|
413 |
+
public function clear_all() {
|
414 |
+
global $wpdb;
|
415 |
+
|
416 |
+
$wpdb->query( "DELETE FROM {$this->main_table}" );
|
417 |
+
$wpdb->query( "DELETE FROM {$this->hashtags_table}" );
|
418 |
+
}
|
419 |
+
|
420 |
+
/**
|
421 |
+
* Add in hashtag table
|
422 |
+
*
|
423 |
+
* @param array $data
|
424 |
+
*
|
425 |
+
* @return boolean|integer
|
426 |
+
* @since 9.0.0
|
427 |
+
* @author Francesco Licandro
|
428 |
+
*/
|
429 |
+
public function add_in_hashtag_table( $data ) {
|
430 |
+
global $wpdb;
|
431 |
+
|
432 |
+
if ( empty( $data['image_id'] ) || empty( $data['hashtag'] ) ) {
|
433 |
+
return false;
|
434 |
+
}
|
435 |
+
|
436 |
+
$id = $wpdb->get_var( "SELECT id FROM {$this->hashtags_table} WHERE image_id = '{$data['image_id']}' AND hashtag = '{$data['hashtag']}'" );
|
437 |
+
if ( $id ) {
|
438 |
+
return false;
|
439 |
+
}
|
440 |
+
|
441 |
+
$table_cols = array(
|
442 |
+
'image_id' => '%s',
|
443 |
+
'hashtag' => '%s',
|
444 |
+
'moderate' => '%s'
|
445 |
+
);
|
446 |
+
|
447 |
+
$format = array_intersect_key( $table_cols, $data );
|
448 |
+
$insert = array_intersect_key( $data, $table_cols );
|
449 |
+
|
450 |
+
$wpdb->insert( $this->hashtags_table, $insert, $format );
|
451 |
+
$id = $wpdb->insert_id;
|
452 |
+
|
453 |
+
return $id;
|
454 |
+
}
|
455 |
+
|
456 |
+
/**
|
457 |
+
* Check if given hashtag exists in table
|
458 |
+
*
|
459 |
+
* @param string $hashtag
|
460 |
+
*
|
461 |
+
* @return boolean
|
462 |
+
* @since 9.1.0
|
463 |
+
*/
|
464 |
+
public function hashtag_exists( $hashtag ) {
|
465 |
+
global $wpdb;
|
466 |
+
$hashtag = esc_sql( $hashtag );
|
467 |
+
$hashtag = $wpdb->get_var( "SELECT hashtag FROM {$this->hashtags_table} WHERE hashtag = '{$hashtag}' LIMIT 1" );
|
468 |
+
|
469 |
+
return ! ! $hashtag;
|
470 |
+
}
|
471 |
+
|
472 |
+
/**
|
473 |
+
* Check if given user has media
|
474 |
+
*
|
475 |
+
* @param string $user
|
476 |
+
*
|
477 |
+
* @return boolean
|
478 |
+
* @since 9.1.0
|
479 |
+
*/
|
480 |
+
public function user_has_media( $user ) {
|
481 |
+
global $wpdb;
|
482 |
+
$user = $wpdb->get_var( "SELECT user FROM {$this->main_table} WHERE user = '{$user}' LIMIT 1" );
|
483 |
+
|
484 |
+
return ! ! $user;
|
485 |
+
}
|
486 |
+
|
487 |
+
/**
|
488 |
+
* Do action if is plugin update
|
489 |
+
*
|
490 |
+
* @return void
|
491 |
+
* @since 9.1.0
|
492 |
+
*/
|
493 |
+
protected function do_action_for_update() {
|
494 |
+
global $wpdb;
|
495 |
+
|
496 |
+
if ( $wpdb->query( "SHOW TABLES LIKE '{$wpdb->prefix}enjoy_instagram_table'" ) ) {
|
497 |
+
// init option
|
498 |
+
update_option( 'enjoyinstagram_sync_times', array(
|
499 |
+
'all' => time() + DAY_IN_SECONDS,
|
500 |
+
'latest' => time() + DAY_IN_SECONDS
|
501 |
+
) );
|
502 |
+
|
503 |
+
$this->_import();
|
504 |
+
}
|
505 |
+
}
|
506 |
+
|
507 |
+
/**
|
508 |
+
* Sync media Ajax
|
509 |
+
*
|
510 |
+
* @return void
|
511 |
+
* @since 9.1.0
|
512 |
+
*/
|
513 |
+
public function import_media_ajax() {
|
514 |
+
// Don't lock up other requests while processing
|
515 |
+
session_write_close();
|
516 |
+
|
517 |
+
if ( ! isset( $_REQUEST['offset'] ) || ! EnjoyInstagram()->verify_communication( $_REQUEST['nonce'],
|
518 |
+
$_REQUEST['action'] ) ) {
|
519 |
+
wp_die();
|
520 |
+
}
|
521 |
+
|
522 |
+
$this->_import( $_REQUEST['offset'] );
|
523 |
+
|
524 |
+
wp_die();
|
525 |
+
}
|
526 |
+
|
527 |
+
/**
|
528 |
+
* Update media
|
529 |
+
*
|
530 |
+
* @param int $offset
|
531 |
+
*
|
532 |
+
* @return void
|
533 |
+
* @since 9.1.0
|
534 |
+
*/
|
535 |
+
private function _import( $offset = 0 ) {
|
536 |
+
|
537 |
+
global $wpdb;
|
538 |
+
|
539 |
+
$offset = intval( $offset );
|
540 |
+
$offset_cond = $offset ? " OFFSET {$offset}" : '';
|
541 |
+
$medias = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}enjoy_instagram_table WHERE image_id NOT LIKE '%http%' AND timestamp > '1527811200' ORDER BY timestamp DESC LIMIT 10 {$offset_cond}",
|
542 |
+
ARRAY_A );
|
543 |
+
|
544 |
+
if ( empty( $medias ) ) {
|
545 |
+
delete_option( 'enjoyinstagram_sync_times' );
|
546 |
+
|
547 |
+
return;
|
548 |
+
}
|
549 |
+
|
550 |
+
foreach ( $medias as $media ) {
|
551 |
+
|
552 |
+
$moderate = $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}enjoy_instagram_moderate_accepted WHERE image_id = '{$media['image_id']}' LIMIT 1" );
|
553 |
+
$moderate && $moderate = 'approved';
|
554 |
+
if ( ! $moderate ) {
|
555 |
+
$moderate = $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}enjoy_instagram_moderate_rejected WHERE image_id = '{$media['image_id']}' LIMIT 1" );
|
556 |
+
$moderate && $moderate = 'rejected';
|
557 |
+
}
|
558 |
+
|
559 |
+
$media_id = $this->add_in_main_table( array(
|
560 |
+
'image_id' => trim( $media['image_id'] ),
|
561 |
+
'image_link' => $media['image_link'],
|
562 |
+
'image_url' => $media['image_url'],
|
563 |
+
'user' => $media['user'],
|
564 |
+
'caption' => str_replace( "\"", """, $media['caption'] ),
|
565 |
+
'likes' => intval( $media['likes'] ),
|
566 |
+
'moderate' => $moderate,
|
567 |
+
'date' => isset( $media['timestamp'] ) ? intval( $media['timestamp'] ) : 0
|
568 |
+
) );
|
569 |
+
|
570 |
+
if ( ! $media['user'] && $media['hashtag'] ) {
|
571 |
+
$this->add_in_hashtag_table( array(
|
572 |
+
'image_id' => $media_id,
|
573 |
+
'hashtag' => $media['hashtag'],
|
574 |
+
'moderate' => $moderate
|
575 |
+
) );
|
576 |
+
}
|
577 |
+
}
|
578 |
+
|
579 |
+
// build remote url
|
580 |
+
$url = admin_url( 'admin-ajax.php' );
|
581 |
+
$url = add_query_arg( array(
|
582 |
+
'action' => $this->import_ajax_action,
|
583 |
+
'nonce' => substr( wp_hash( $this->import_ajax_action . '|' . $this->ajax_key, 'nonce' ), - 12, 10 ),
|
584 |
+
'offset' => $offset + 10,
|
585 |
+
), $url );
|
586 |
+
|
587 |
+
wp_remote_post( $url );
|
588 |
+
}
|
589 |
+
}
|
590 |
+
|
591 |
+
/**
|
592 |
+
* Unique access to instance of EnjoyInstagram_DB class
|
593 |
+
*
|
594 |
+
* @return \EnjoyInstagram_DB
|
595 |
+
* @since 9.0.0
|
596 |
+
*/
|
597 |
+
function EnjoyInstagram_DB() {
|
598 |
+
return EnjoyInstagram_DB::get_instance();
|
599 |
+
}
|
600 |
+
|
601 |
+
EnjoyInstagram_DB();
|
includes/class.enjoyinstagram-shortcodes.php
CHANGED
@@ -3,286 +3,308 @@
|
|
3 |
* This class handles plugin shortcodes
|
4 |
*/
|
5 |
|
6 |
-
if( ! defined( 'ABSPATH' ) ) {
|
7 |
-
|
8 |
}
|
9 |
|
10 |
class EnjoyInstagram_Shortcodes {
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
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 |
<script type="text/javascript">
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
});
|
123 |
-
|
124 |
});
|
|
|
|
|
125 |
</script>
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
}
|
277 |
|
278 |
/**
|
279 |
* Unique access to instance of EnjoyInstagram_Shortcodes class
|
280 |
*
|
281 |
-
* @return
|
282 |
* @since 9.0.0
|
283 |
*/
|
284 |
function EnjoyInstagram_Shortcodes() {
|
285 |
-
|
286 |
}
|
287 |
|
288 |
EnjoyInstagram_Shortcodes();
|
3 |
* This class handles plugin shortcodes
|
4 |
*/
|
5 |
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // exit if call directly
|
8 |
}
|
9 |
|
10 |
class EnjoyInstagram_Shortcodes {
|
11 |
|
12 |
+
/**
|
13 |
+
* Single plugin instance
|
14 |
+
* @since 9.0.0
|
15 |
+
* @var EnjoyInstagram_Shortcodes
|
16 |
+
*/
|
17 |
+
protected static $instance;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Shortcode index
|
21 |
+
* @since 9.0.0
|
22 |
+
* @var integer
|
23 |
+
*/
|
24 |
+
public static $index = 1;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @since 9.0.0
|
28 |
+
* @var boolean
|
29 |
+
*/
|
30 |
+
public $enqueued = false;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Returns single instance of the class
|
34 |
+
*
|
35 |
+
* @return EnjoyInstagram_Shortcodes
|
36 |
+
* @since 1.0.0
|
37 |
+
*/
|
38 |
+
public static function get_instance() {
|
39 |
+
if ( is_null( self::$instance ) ) {
|
40 |
+
self::$instance = new self();
|
41 |
+
}
|
42 |
+
|
43 |
+
return self::$instance;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Construct
|
48 |
+
*
|
49 |
+
* @return void
|
50 |
+
*/
|
51 |
+
public function __construct() {
|
52 |
+
// register common scripts
|
53 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ), 5 );
|
54 |
+
add_action( 'wp_head', array( $this, 'functions_in_head' ) );
|
55 |
+
if ( ! is_admin() ) {
|
56 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 15 );
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
add_shortcode( 'enjoyinstagram_mb', array( $this, 'carousel_shortcode' ) );
|
61 |
+
add_shortcode( 'enjoyinstagram_mb_grid', array( $this, 'grid_shortcode' ) );
|
62 |
+
add_shortcode( 'enjoyinstagram_mb_widget', array( $this, 'carousel_shortcode_widget' ) );
|
63 |
+
add_shortcode( 'enjoyinstagram_mb_grid_widget', array( $this, 'grid_shortcode_widget' ) );
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Register common scripts
|
68 |
+
*
|
69 |
+
* @return void
|
70 |
+
* @since 4.0.0
|
71 |
+
*/
|
72 |
+
public function register_scripts() {
|
73 |
+
wp_register_script( 'owl', ENJOYINSTAGRAM_ASSETS_URL . '/js/owl.carousel.min.js', array( 'jquery' ),
|
74 |
+
ENJOYINSTAGRAM_VERSION );
|
75 |
+
wp_register_script( 'swipebox', ENJOYINSTAGRAM_ASSETS_URL . '/js/jquery.swipebox.min.js', array( 'jquery' ),
|
76 |
+
ENJOYINSTAGRAM_VERSION );
|
77 |
+
wp_register_script( 'gridrotator', ENJOYINSTAGRAM_ASSETS_URL . '/js/jquery.gridrotator.min.js',
|
78 |
+
array( 'jquery' ), ENJOYINSTAGRAM_VERSION );
|
79 |
+
wp_register_script( 'modernizr.custom.26633', ENJOYINSTAGRAM_ASSETS_URL . '/js/modernizr.custom.26633.min.js',
|
80 |
+
array( 'jquery' ), ENJOYINSTAGRAM_VERSION );
|
81 |
+
wp_register_script( 'orientationchange', ENJOYINSTAGRAM_ASSETS_URL . '/js/ios-orientationchange-fix.min.js',
|
82 |
+
array( 'jquery' ), ENJOYINSTAGRAM_VERSION );
|
83 |
+
|
84 |
+
wp_register_style( 'owl_style', ENJOYINSTAGRAM_ASSETS_URL . '/css/owl.carousel.css' );
|
85 |
+
wp_register_style( 'owl_style_2', ENJOYINSTAGRAM_ASSETS_URL . '/css/owl.theme.css' );
|
86 |
+
wp_register_style( 'owl_style_3', ENJOYINSTAGRAM_ASSETS_URL . '/css/owl.transitions.css' );
|
87 |
+
wp_register_style( 'swipebox_css', ENJOYINSTAGRAM_ASSETS_URL . '/css/swipebox.css' );
|
88 |
+
wp_register_style( 'grid_fallback', ENJOYINSTAGRAM_ASSETS_URL . '/css/grid_fallback.css' );
|
89 |
+
wp_register_style( 'grid_style', ENJOYINSTAGRAM_ASSETS_URL . '/css/grid_style.css' );
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Enqueue scripts ans styles
|
94 |
+
*
|
95 |
+
* @since 4.0.0
|
96 |
+
*/
|
97 |
+
public function enqueue_scripts() {
|
98 |
+
|
99 |
+
if ( $this->enqueued ) {
|
100 |
+
return;
|
101 |
+
}
|
102 |
+
wp_enqueue_script( 'modernizr.custom.26633' );
|
103 |
+
wp_enqueue_script( 'gridrotator' );
|
104 |
+
wp_localize_script( 'gridrotator', 'GridRotator', array( 'pluginsUrl' => plugins_url(), ) );
|
105 |
+
wp_enqueue_script( 'owl' );
|
106 |
+
wp_enqueue_script( 'swipebox' );
|
107 |
+
wp_enqueue_script( 'orientationchange' );
|
108 |
+
wp_enqueue_style( 'owl_style' );
|
109 |
+
wp_enqueue_style( 'owl_style_2' );
|
110 |
+
wp_enqueue_style( 'owl_style_3' );
|
111 |
+
wp_enqueue_style( 'swipebox_css' );
|
112 |
+
wp_enqueue_style( 'grid_fallback' );
|
113 |
+
wp_enqueue_style( 'grid_style' );
|
114 |
+
|
115 |
+
$this->enqueued = true;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* JS functions in head
|
120 |
+
*
|
121 |
+
* @since 4.0.0
|
122 |
+
*/
|
123 |
+
public function functions_in_head() {
|
124 |
+
?>
|
125 |
<script type="text/javascript">
|
126 |
+
jQuery(function ($) {
|
127 |
+
$(".swipebox_grid").swipebox({
|
128 |
+
hideBarsDelay: 0
|
|
|
|
|
129 |
});
|
130 |
+
|
131 |
+
});
|
132 |
</script>
|
133 |
+
<?php
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Get shortcode data
|
138 |
+
*
|
139 |
+
* @param string $type
|
140 |
+
*
|
141 |
+
* @return array
|
142 |
+
* @since 4.0.0
|
143 |
+
*/
|
144 |
+
protected function _get_shortcode_data( $type = '' ) {
|
145 |
+
|
146 |
+
! $type && $type = get_option( 'enjoyinstagram_user_or_hashtag', 'user' );
|
147 |
+
|
148 |
+
$user = EnjoyInstagram()->get_selected_user();
|
149 |
+
$hashtags = array_map( 'trim', explode( ',', get_option( 'enjoyinstagram_hashtag' ) ) );
|
150 |
+
$medias = array();
|
151 |
+
|
152 |
+
if ( $type === 'hashtag' ) {
|
153 |
+
$medias = EnjoyInstagram_DB()->get_shortcode_media_hashtag( $hashtags, false,
|
154 |
+
20 );
|
155 |
+
} else if ( $type === 'user' ) {
|
156 |
+
$medias = EnjoyInstagram_DB()->get_shortcode_media_user( $user['username'], array(), false, 20 );
|
157 |
+
} else if ( $type === 'public_hashtag' && $user['business'] ) {
|
158 |
+
$medias = EnjoyInstagram_Api_Connection()->search_business_hashtag( $user, $hashtags[0], 20 );
|
159 |
+
}
|
160 |
+
|
161 |
+
if ( count( $medias ) > 0 ) {
|
162 |
+
foreach ( $medias as $key => &$entry ) {
|
163 |
+
$entry = enjoyinstagram_format_entry_before_print( $entry );
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
return $medias;
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Carousel shortcode callback
|
172 |
+
*
|
173 |
+
* @param array $atts
|
174 |
+
*
|
175 |
+
* @return string
|
176 |
+
* @since 4.0.0
|
177 |
+
*/
|
178 |
+
public function carousel_shortcode( $atts ) {
|
179 |
+
extract( shortcode_atts( array(
|
180 |
+
'n' => '4'
|
181 |
+
), $atts ) );
|
182 |
+
|
183 |
+
|
184 |
+
if ( ! EnjoyInstagram()->get_selected_user() ) {
|
185 |
+
return '';
|
186 |
+
}
|
187 |
+
|
188 |
+
$items_num = get_option( 'enjoyinstagram_carousel_items_number', '4' );
|
189 |
+
$nav = get_option( 'enjoyinstagram_carousel_navigation', 'false' );
|
190 |
+
$result = $this->_get_shortcode_data();
|
191 |
+
if ( empty( $result ) ) {
|
192 |
+
return '';
|
193 |
+
}
|
194 |
+
$i = self::$index;
|
195 |
+
self::$index ++;
|
196 |
+
|
197 |
+
ob_start();
|
198 |
+
include( ENJOYINSTAGRAM_TEMPLATE_PATH . '/shortcodes/carousel.php' );
|
199 |
+
|
200 |
+
return ob_get_clean();
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Grid shortcode callback
|
205 |
+
*
|
206 |
+
* @param array $atts
|
207 |
+
*
|
208 |
+
* @return string
|
209 |
+
* @since 4.0.0
|
210 |
+
*/
|
211 |
+
public function grid_shortcode( $atts ) {
|
212 |
+
extract( shortcode_atts( array(
|
213 |
+
'rows' => get_option( 'enjoyinstagram_grid_rows', '2' ),
|
214 |
+
'cols' => get_option( 'enjoyinstagram_grid_cols', '5' )
|
215 |
+
), $atts ) );
|
216 |
+
|
217 |
+
if ( ! EnjoyInstagram()->get_selected_user() ) {
|
218 |
+
return '';
|
219 |
+
}
|
220 |
+
|
221 |
+
$result = $this->_get_shortcode_data();
|
222 |
+
if ( empty( $result ) ) {
|
223 |
+
return '';
|
224 |
+
}
|
225 |
+
$i = self::$index;
|
226 |
+
self::$index ++;
|
227 |
+
|
228 |
+
ob_start();
|
229 |
+
include( ENJOYINSTAGRAM_TEMPLATE_PATH . '/shortcodes/grid.php' );
|
230 |
+
|
231 |
+
return ob_get_clean();
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* Carousel shortcode widget callback
|
236 |
+
*
|
237 |
+
* @param array $atts
|
238 |
+
*
|
239 |
+
* @return string
|
240 |
+
* @since 4.0.0
|
241 |
+
*/
|
242 |
+
public function carousel_shortcode_widget( $atts ) {
|
243 |
+
extract( shortcode_atts( array(
|
244 |
+
'n' => '4',
|
245 |
+
'id' => 'owl',
|
246 |
+
'n_y_n' => 'false',
|
247 |
+
'u_or_h' => 'user'
|
248 |
+
), $atts ) );
|
249 |
+
|
250 |
+
if ( ! EnjoyInstagram()->get_selected_user() ) {
|
251 |
+
return '';
|
252 |
+
}
|
253 |
+
|
254 |
+
$result = $this->_get_shortcode_data( $u_or_h );
|
255 |
+
if ( empty( $result ) ) {
|
256 |
+
return '';
|
257 |
+
}
|
258 |
+
|
259 |
+
$i = self::$index;
|
260 |
+
self::$index ++;
|
261 |
+
|
262 |
+
ob_start();
|
263 |
+
include( ENJOYINSTAGRAM_TEMPLATE_PATH . '/shortcodes/carousel-widget.php' );
|
264 |
+
|
265 |
+
return ob_get_clean();
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Grid shortcode widget callback
|
270 |
+
*
|
271 |
+
* @param array $atts
|
272 |
+
*
|
273 |
+
* @return string
|
274 |
+
* @since 4.0.0
|
275 |
+
*/
|
276 |
+
public function grid_shortcode_widget( $atts ) {
|
277 |
+
extract( shortcode_atts( array(
|
278 |
+
'id' => 'rigrid_default',
|
279 |
+
'n_c' => '6',
|
280 |
+
'n_r' => '2',
|
281 |
+
'u_or_h' => 'user'
|
282 |
+
), $atts ) );
|
283 |
+
|
284 |
+
if ( ! EnjoyInstagram()->get_selected_user() ) {
|
285 |
+
return '';
|
286 |
+
}
|
287 |
+
|
288 |
+
$result = $this->_get_shortcode_data( $u_or_h );
|
289 |
+
if ( empty( $result ) ) {
|
290 |
+
return '';
|
291 |
+
}
|
292 |
+
|
293 |
+
ob_start();
|
294 |
+
include( ENJOYINSTAGRAM_TEMPLATE_PATH . '/shortcodes/grid-widget.php' );
|
295 |
+
|
296 |
+
return ob_get_clean();
|
297 |
+
}
|
298 |
}
|
299 |
|
300 |
/**
|
301 |
* Unique access to instance of EnjoyInstagram_Shortcodes class
|
302 |
*
|
303 |
+
* @return EnjoyInstagram_Shortcodes
|
304 |
* @since 9.0.0
|
305 |
*/
|
306 |
function EnjoyInstagram_Shortcodes() {
|
307 |
+
return EnjoyInstagram_Shortcodes::get_instance();
|
308 |
}
|
309 |
|
310 |
EnjoyInstagram_Shortcodes();
|
includes/class.enjoyinstagram.php
ADDED
@@ -0,0 +1,298 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This main plugin class
|
4 |
+
*/
|
5 |
+
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // exit if call directly
|
8 |
+
}
|
9 |
+
|
10 |
+
final class EnjoyInstagram {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Single plugin instance
|
14 |
+
* @since 9.0.0
|
15 |
+
* @var \EnjoyInstagram_Admin
|
16 |
+
*/
|
17 |
+
protected static $instance;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Plugin users array
|
21 |
+
* @var array
|
22 |
+
*/
|
23 |
+
private $_users = [];
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Returns single instance of the class
|
27 |
+
*
|
28 |
+
* @return EnjoyInstagram
|
29 |
+
* @since 1.0.0
|
30 |
+
*/
|
31 |
+
public static function get_instance() {
|
32 |
+
if ( is_null( self::$instance ) ) {
|
33 |
+
self::$instance = new self();
|
34 |
+
}
|
35 |
+
|
36 |
+
return self::$instance;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Construct
|
41 |
+
*
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
private function __construct() {
|
45 |
+
$this->_load_required();
|
46 |
+
$this->_users = (array) get_option( 'enjoy_instagram_options', array() );
|
47 |
+
$this->_users = array_filter( $this->_users );
|
48 |
+
|
49 |
+
// sync actions
|
50 |
+
add_action( 'init', array( $this, 'schedule_sync' ), 1 );
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Load required files
|
55 |
+
*
|
56 |
+
* @return void
|
57 |
+
* @since 11.0.0
|
58 |
+
*/
|
59 |
+
private function _load_required() {
|
60 |
+
// common file
|
61 |
+
require_once( 'class.enjoyinstagram-api-connection.php' );
|
62 |
+
require_once( 'class.enjoyinstagram-db.php' );
|
63 |
+
require_once( 'class.enjoyinstagram-shortcodes.php' );
|
64 |
+
// widgets
|
65 |
+
require_once( 'widgets/widgets.php' );
|
66 |
+
require_once( 'widgets/widgets_grid.php' );
|
67 |
+
|
68 |
+
// require admin class
|
69 |
+
if ( is_admin() ) {
|
70 |
+
include_once( 'tinymce/tinymce.php' );
|
71 |
+
require_once( 'class.enjoyinstagram-admin.php' );
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Get the first logged user. Helper for free plugin
|
77 |
+
*
|
78 |
+
* @return array|false
|
79 |
+
*/
|
80 |
+
public function get_selected_user() {
|
81 |
+
return count( $this->_users ) > 0 ? array_values( $this->_users )[0] : false;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Get the users array
|
86 |
+
*
|
87 |
+
* @return array
|
88 |
+
* @since 11.0.0
|
89 |
+
*/
|
90 |
+
public function get_users() {
|
91 |
+
return $this->_users;
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Get a single user by id
|
96 |
+
*
|
97 |
+
* @param string $id
|
98 |
+
*
|
99 |
+
* @return array|boolean
|
100 |
+
* @since 11.0.0
|
101 |
+
*/
|
102 |
+
public function get_user( $id ) {
|
103 |
+
return isset( $this->_users[ $id ] ) ? $this->_users[ $id ] : false;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* There is a business user?
|
108 |
+
*
|
109 |
+
* @return string|boolean
|
110 |
+
* @since 11.0.0
|
111 |
+
*/
|
112 |
+
public function has_business_user() {
|
113 |
+
if ( empty( $this->_users ) ) {
|
114 |
+
return false;
|
115 |
+
}
|
116 |
+
|
117 |
+
foreach ( $this->_users as $id => $data ) {
|
118 |
+
if ( ! empty( $data['business'] ) ) {
|
119 |
+
return $id;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
return false;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Add an user to main array
|
128 |
+
*
|
129 |
+
* @param string $id
|
130 |
+
* @param array $data
|
131 |
+
*
|
132 |
+
* @since 11.0.0
|
133 |
+
*/
|
134 |
+
public function add_user( $id, $data ) {
|
135 |
+
$this->_users[ $id ] = $data;
|
136 |
+
|
137 |
+
update_option( 'enjoy_instagram_options', $this->_users );
|
138 |
+
// force sync
|
139 |
+
delete_option( 'enjoyinstagram_sync_times' );
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Remove an user
|
144 |
+
*
|
145 |
+
* @param string $id
|
146 |
+
*
|
147 |
+
* @return boolean
|
148 |
+
* @since 11.0.0
|
149 |
+
*/
|
150 |
+
public function remove_user( $id ) {
|
151 |
+
unset( $this->_users[ $id ] );
|
152 |
+
update_option( 'enjoy_instagram_options', $this->_users );
|
153 |
+
|
154 |
+
EnjoyInstagram_DB()->delete_media_by_user( $id ); // delete also media and hashtags
|
155 |
+
|
156 |
+
return true;
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Schedule event sync. Use cron if active, otherwise use custom
|
161 |
+
*
|
162 |
+
* @param boolean $force If force the update. Valid only for latest
|
163 |
+
*
|
164 |
+
* @return void
|
165 |
+
* @since 9.1.0
|
166 |
+
*/
|
167 |
+
public function schedule_sync( $force = false ) {
|
168 |
+
|
169 |
+
if ( empty( $this->_users ) || defined('DOING_AJAX') ) {
|
170 |
+
return;
|
171 |
+
};
|
172 |
+
|
173 |
+
$times = get_option( 'enjoyinstagram_sync_times', array() );
|
174 |
+
$current = time();
|
175 |
+
|
176 |
+
foreach ( $this->_users as $user => $user_data ) {
|
177 |
+
$latest = isset( $times[ $user ] ) ? intval( $times[ $user ] ) : 0;
|
178 |
+
if ( $current > ( $latest + DAY_IN_SECONDS ) ) {
|
179 |
+
$this->sync_users_data( $user ); // sync also data
|
180 |
+
$this->sync_media_event( $user, 'all' );
|
181 |
+
// update time
|
182 |
+
$times[ $user ] = $current;
|
183 |
+
} elseif ( $force || ( $current > ( $latest + ( 5 * MINUTE_IN_SECONDS ) ) ) ) {
|
184 |
+
$this->sync_media_event( $user, 'latest' );
|
185 |
+
// update time
|
186 |
+
$times[ $user ] = $current;
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
update_option( 'enjoyinstagram_sync_times', $times );
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Sync user data scheduled
|
195 |
+
*
|
196 |
+
* @param string $user
|
197 |
+
*
|
198 |
+
* @return void
|
199 |
+
* @since 10.0.1
|
200 |
+
*/
|
201 |
+
protected function sync_users_data( $user ) {
|
202 |
+
|
203 |
+
if ( ! isset( $this->_users[ $user ] ) ) {
|
204 |
+
return;
|
205 |
+
}
|
206 |
+
|
207 |
+
$user_data = $this->_users[ $user ];
|
208 |
+
|
209 |
+
$api = EnjoyInstagram_Api_Connection();
|
210 |
+
$data = $api->get_user_profile( $user_data['access_token'], $user_data['business'] );
|
211 |
+
|
212 |
+
|
213 |
+
if ( $data === false && ! empty( $api->last_error ) ) {
|
214 |
+
enjoyinstagram_add_notice( $api->last_error, 'error' );
|
215 |
+
} else {
|
216 |
+
$this->_users[ $user ] = array_merge( $this->_users[ $user ], $data );
|
217 |
+
}
|
218 |
+
|
219 |
+
update_option( 'enjoy_instagram_options', $this->_users );
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Sync user media event scheduled
|
224 |
+
*
|
225 |
+
* @param string $to_sync The media to sync (latest|all)
|
226 |
+
* @param string $user
|
227 |
+
*
|
228 |
+
* @return void
|
229 |
+
* @since 9.1.0
|
230 |
+
*/
|
231 |
+
public function sync_media_event( $user, $to_sync = 'latest' ) {
|
232 |
+
if ( ! isset( $this->_users[ $user ] ) ) {
|
233 |
+
return;
|
234 |
+
}
|
235 |
+
|
236 |
+
$this->_sync( $user, $to_sync );
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Sync media
|
241 |
+
*
|
242 |
+
* @param string $user
|
243 |
+
* @param string $to_sync
|
244 |
+
* @param string $offset
|
245 |
+
*
|
246 |
+
* @return void
|
247 |
+
* @since 9.1.0
|
248 |
+
*/
|
249 |
+
private function _sync( $user, $to_sync = 'latest', $offset = '' ) {
|
250 |
+
|
251 |
+
$user_data = ! empty( $this->_users[ $user ] ) ? $this->_users[ $user ] : false;
|
252 |
+
if ( ! $user_data ) {
|
253 |
+
return;
|
254 |
+
}
|
255 |
+
|
256 |
+
$api = EnjoyInstagram_Api_Connection();
|
257 |
+
$medias = $api->get_user_media( $user_data, 33, $offset );
|
258 |
+
|
259 |
+
if ( empty( $medias['data'] ) && ! empty( $api->last_error ) ) {
|
260 |
+
$error_msg = sprintf( __( 'An error occurred while syncing the media: %s', 'enjoyinstagram' ),
|
261 |
+
$api->last_error );
|
262 |
+
enjoyinstagram_add_notice( $error_msg, 'error' );
|
263 |
+
|
264 |
+
return;
|
265 |
+
}
|
266 |
+
|
267 |
+
foreach ( $medias['data'] as $media ) {
|
268 |
+
if ( empty( $media['image_id'] ) ) {
|
269 |
+
continue;
|
270 |
+
}
|
271 |
+
|
272 |
+
$media_id = EnjoyInstagram_DB()->add_in_main_table( $media );
|
273 |
+
if ( $media_id && ! empty( $media['tags'] ) ) {
|
274 |
+
foreach ( $media['tags'] as $tag ) {
|
275 |
+
EnjoyInstagram_DB()->add_in_hashtag_table( array(
|
276 |
+
'image_id' => $media_id,
|
277 |
+
'hashtag' => esc_sql( $tag )
|
278 |
+
) );
|
279 |
+
}
|
280 |
+
}
|
281 |
+
}
|
282 |
+
|
283 |
+
// continue sync
|
284 |
+
if ( $to_sync == 'all' && ! empty( $medias['next'] ) ) {
|
285 |
+
$this->_sync( $user, $to_sync, $medias['next'] );
|
286 |
+
}
|
287 |
+
}
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Unique access to instance of EnjoyInstagram class
|
292 |
+
*
|
293 |
+
* @return EnjoyInstagram
|
294 |
+
* @since 9.0.0
|
295 |
+
*/
|
296 |
+
function EnjoyInstagram() {
|
297 |
+
return EnjoyInstagram::get_instance();
|
298 |
+
}
|
includes/functions.enjoyinstagram.php
CHANGED
@@ -3,118 +3,140 @@
|
|
3 |
* Common functions for plugin Enjoy Instagram
|
4 |
*/
|
5 |
|
6 |
-
if( ! defined( 'ABSPATH' ) ) {
|
7 |
-
|
8 |
-
}
|
9 |
-
|
10 |
-
if( ! function_exists( 'enjoyinstagram_shuffle_assoc' ) ) {
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
}
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
33 |
\xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
|
34 |
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
|
35 |
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
|
36 |
-
)%xs', '', $string);
|
37 |
-
|
38 |
-
}
|
39 |
-
|
40 |
-
if( ! function_exists( 'enjoyinstagram_isHttps' ) ) {
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
}
|
50 |
-
|
51 |
-
if( ! function_exists( 'enjoyinstagram_format_entry_before_print' ) ) {
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
}
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
}
|
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 |
-
function
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
}
|
3 |
* Common functions for plugin Enjoy Instagram
|
4 |
*/
|
5 |
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // exit if call directly
|
8 |
+
}
|
9 |
+
|
10 |
+
if ( ! function_exists( 'enjoyinstagram_shuffle_assoc' ) ) {
|
11 |
+
function enjoyinstagram_shuffle_assoc( &$array ) {
|
12 |
+
if ( empty( $array ) ) {
|
13 |
+
return false;
|
14 |
+
}
|
15 |
+
|
16 |
+
$keys = array_keys( $array );
|
17 |
+
shuffle( $keys );
|
18 |
+
foreach ( $keys as $key ) {
|
19 |
+
$new[ $key ] = $array[ $key ];
|
20 |
+
}
|
21 |
+
$array = $new;
|
22 |
+
|
23 |
+
return true;
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
if ( ! function_exists( 'enjoyinstagram_replace4byte' ) ) {
|
28 |
+
/**
|
29 |
+
* @param $string
|
30 |
+
*
|
31 |
+
* @return null|string|string[]
|
32 |
+
*/
|
33 |
+
function enjoyinstagram_replace4byte( $string ) {
|
34 |
+
return preg_replace( '%(?:
|
35 |
\xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
|
36 |
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
|
37 |
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
|
38 |
+
)%xs', '', $string );
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
if ( ! function_exists( 'enjoyinstagram_isHttps' ) ) {
|
43 |
+
/**
|
44 |
+
* Check HTTPS
|
45 |
+
*
|
46 |
+
* @return bool
|
47 |
+
*/
|
48 |
+
function enjoyinstagram_isHttps() {
|
49 |
+
return ! empty( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] != 'off';
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
if ( ! function_exists( 'enjoyinstagram_format_entry_before_print' ) ) {
|
54 |
+
/**
|
55 |
+
* Format an entry before print
|
56 |
+
*
|
57 |
+
* @param array $entry
|
58 |
+
*
|
59 |
+
* @return array
|
60 |
+
* @since 4.0.0
|
61 |
+
*/
|
62 |
+
function enjoyinstagram_format_entry_before_print( $entry ) {
|
63 |
+
$entry['caption'] = array(
|
64 |
+
'text' => ! empty( $entry['caption'] ) ? str_replace( "\"", """,
|
65 |
+
$entry['caption'] ) : ''
|
66 |
+
);
|
67 |
+
|
68 |
+
$entry['images'] = array(
|
69 |
+
'thumbnail' => array( 'url' => $entry['image_url'] ),
|
70 |
+
'standard_resolution' => array( 'url' => $entry['image_url'] )
|
71 |
+
);
|
72 |
+
|
73 |
+
if ( enjoyinstagram_isHttps() ) {
|
74 |
+
$entry['images']['thumbnail']['url'] = str_replace( 'http://', 'https://',
|
75 |
+
$entry['image_url'] );
|
76 |
+
$entry['images']['standard_resolution']['url'] = str_replace( 'http://', 'https://',
|
77 |
+
$entry['image_url'] );
|
78 |
+
}
|
79 |
+
|
80 |
+
return $entry;
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
if ( ! function_exists( 'enjoyinstagram_add_notice' ) ) {
|
85 |
+
/**
|
86 |
+
* Add a flash message. It will be displayed in the admin_notice section
|
87 |
+
*
|
88 |
+
* @param string $message
|
89 |
+
* @param string $type
|
90 |
+
*
|
91 |
+
* @return void
|
92 |
+
* @author Giulio Ganci
|
93 |
+
* @since 11.0.0
|
94 |
+
*/
|
95 |
+
function enjoyinstagram_add_notice( $message, $type ) {
|
96 |
+
$notices = enjoyinstagram_get_notices();
|
97 |
+
$notices[] = array( 'message' => $message, 'type' => $type );
|
98 |
+
set_transient( 'enjoyinstagram_notices', $notices );
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
if ( ! function_exists( 'enjoyinstagram_get_notices' ) ) {
|
103 |
+
/**
|
104 |
+
* Return the flash messages that will be displayed in admin_notice section
|
105 |
+
*
|
106 |
+
* @param bool $delete
|
107 |
+
*
|
108 |
+
* @return array
|
109 |
+
* @author Giulio Ganci
|
110 |
+
* @since 11.0.0
|
111 |
+
*/
|
112 |
+
function enjoyinstagram_get_notices( $delete = true ) {
|
113 |
+
$notices = get_transient( 'enjoyinstagram_notices' );
|
114 |
+
if ( ! $notices ) {
|
115 |
+
return [];
|
116 |
+
}
|
117 |
+
|
118 |
+
if ( $delete ) {
|
119 |
+
delete_transient( 'enjoyinstagram_notices' );
|
120 |
+
}
|
121 |
+
|
122 |
+
return $notices;
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
if ( ! function_exists( 'enjoyinstagram_extract_hashtags' ) ) {
|
127 |
+
/**
|
128 |
+
* Return the hashtags from a given text
|
129 |
+
*
|
130 |
+
* @param string $string
|
131 |
+
*
|
132 |
+
* @return array
|
133 |
+
* @author Giulio Ganci
|
134 |
+
* @since 11.0.0
|
135 |
+
*/
|
136 |
+
function enjoyinstagram_extract_hashtags( $string ) {
|
137 |
+
$regex = '/(^|[^0-9A-Z&\/\?]+)([##]+)([0-9A-Z_]*[A-Z_]+[a-z0-9_üÀ-ÖØ-öø-ÿ]*)/iu';
|
138 |
+
preg_match_all( $regex, $string, $matches );
|
139 |
+
|
140 |
+
return $matches[3];
|
141 |
+
}
|
142 |
}
|
readme.txt
CHANGED
@@ -1,42 +1,51 @@
|
|
1 |
-
=== Enjoy
|
2 |
Contributors: mediabeta
|
3 |
Donate link: https://www.google.com/url?q=https%3A%2F%2Fwww.paypal.com%2Fcgi-bin%2Fwebscr%3Fcmd%3D_s-xclick%26hosted_button_id%3D8MXZ37DWHAX46&sa=D&sntz=1&usg=AFQjCNFHixLdowdc2AAEXDYmM9tQBl-TXQ
|
4 |
Tags: Instagram, Instagram feed, Instagram Widget, Instagram grid, Instagram carousel, Embed Instagram, Embed Instagram feed, Instagram feed on website, responsive carousel, WordPress carousel, Instagram gallery, Instagram WordPress, Instagram pictures
|
5 |
Requires at least: 4.0
|
6 |
-
Tested up to: 5.
|
7 |
-
Version:
|
8 |
-
Stable tag:
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
12 |
-
Instagram feed
|
13 |
|
14 |
== Description ==
|
15 |
|
16 |
-
=
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
Each Instagram photo can be shown in Carousel and Grid mode with Lightbox effect.
|
20 |
-
Enjoy
|
21 |
|
22 |
-
Once you have installed our plugin Enjoy
|
23 |
|
24 |
-
= Here is Live Demo for Enjoy
|
25 |
|
26 |
-
= Enjoy Plugin for
|
27 |
|
28 |
-
|
29 |
|
30 |
-
*
|
|
|
31 |
* Profile-based Instagram feed to show photos by Instagram profiles
|
32 |
-
* Instagram video visualization
|
33 |
* Instagram Widget for sidebars to publish Instagram feed with carousel and grid visualization
|
34 |
* Instagram Carousel feed and Instagram Grid feed to add with Shortcode
|
35 |
* Shortcode button in the editor page and post
|
36 |
|
37 |
|
38 |
* Pictures Transition for carousel: one picture / more pictures at a time
|
39 |
-
* Option for activating Navigation in
|
40 |
* Customization for Number of Instagram pictures to see in the same time
|
41 |
|
42 |
* Number of columns and rows customizable
|
@@ -53,17 +62,17 @@ Once you have installed our plugin Enjoy Instagram, thanks to the presence of En
|
|
53 |
* One click set up.
|
54 |
* Php 7 compatible
|
55 |
|
56 |
-
= Very Simple Installation and Configuration for Enjoy
|
57 |
|
58 |
[http://www.mediabetaprojects.com/enjoy-instagram-premium/install-enjoy-instagram-wordpress-plugin/](http://www.mediabetaprojects.com/enjoy-instagram-premium/install-enjoy-instagram-wordpress-plugin/)
|
59 |
|
60 |
-
= Enjoy
|
61 |
|
62 |
-
Enjoy
|
63 |
The last plugin version now supports multi hashtags and profiles, pictures with square format, grid view with a border between pictures.
|
64 |
|
65 |
|
66 |
-
|
67 |
|
68 |
* More shortcodes in the same page or post to display multiple instagram feeds
|
69 |
* More shortcodes for different hashtags or profiles in the same page or post
|
@@ -76,6 +85,9 @@ The last plugin version now supports multi hashtags and profiles, pictures with
|
|
76 |
* Instagram Carousel, Instagram Grid, Instagram Polaroid, Instagram Album and Badge view
|
77 |
* On click, Pictures of different views can be redirected to Instagram page, to a particular website or opened in a Lightbox
|
78 |
* The Lightbox displays Instagram pictures as a slideshow with media caption
|
|
|
|
|
|
|
79 |
* NEW - Performance improved
|
80 |
* NEW - Cleaned and optimizated code
|
81 |
* NEW - Improved css and js loading
|
@@ -88,14 +100,14 @@ For Lightbox you can set:
|
|
88 |
* to Show Likes Count
|
89 |
* to Show author
|
90 |
|
91 |
-
<strong>
|
92 |
-
Instagram Widget is one feature of Enjoy
|
93 |
Once you installed it, you will be able to use Carousel and Grid widget in the dedicated Section.
|
94 |
|
95 |
-
You will have only to drag the widget
|
96 |
[DEMO for Instagram Widget on website WordPress](https://www.mediabetaprojects.com/enjoy-instagram-premium/widget-instagram-on-your-website-how-to/)
|
97 |
|
98 |
-
=
|
99 |
* images displayed at a time
|
100 |
* animation in / animation out
|
101 |
* show different number of images for different screen resolution
|
@@ -104,7 +116,7 @@ You will have only to drag the widget “Enjoy Instagram” in the sidebar you w
|
|
104 |
|
105 |
[DEMO for Instagram Carousel feed on website WordPress](https://www.mediabetaprojects.com/enjoy-instagram-premium/carousel-view-instagram-wordpress-plugin/)
|
106 |
|
107 |
-
=
|
108 |
* the number of rows and columns for the different shortcodes
|
109 |
* the number of images that are replaced at the same time
|
110 |
* interval the images will be replaced
|
@@ -113,7 +125,7 @@ You will have only to drag the widget “Enjoy Instagram” in the sidebar you w
|
|
113 |
|
114 |
[DEMO for Instagram Grid feed on website WordPress](https://www.mediabetaprojects.com/enjoy-instagram-premium/grid-view-instagram-plugin/)
|
115 |
|
116 |
-
=
|
117 |
* to show info (caption) on back
|
118 |
* color background, border width, border color
|
119 |
|
@@ -130,12 +142,12 @@ See Also demo for:
|
|
130 |
= See LIVE PREVIEW: =
|
131 |
[http://www.mediabetaprojects.com/enjoy-instagram-premium/](http://www.mediabetaprojects.com/enjoy-instagram-premium/)
|
132 |
|
133 |
-
=
|
134 |
|
135 |
* Instagram Album View to show your pictures organized for Instagram username and or Instagram hashtags
|
136 |
* Instagram Badge View that will help you link to and promote your Instagram web profile
|
137 |
* Autoreload Stream of Instagram Photos
|
138 |
-
*
|
139 |
[youtube https://www.youtube.com/watch?v=W6gNqlghbLE]
|
140 |
* Autoplay
|
141 |
* Loop
|
@@ -147,29 +159,27 @@ See Also demo for:
|
|
147 |
|
148 |
and many others features..
|
149 |
|
150 |
-
= LIVE PREMIUM VERSION DEMO for Enjoy
|
151 |
[http://www.mediabetaprojects.com/enjoy-instagram-premium/](http://www.mediabetaprojects.com/enjoy-instagram-premium/)
|
152 |
|
153 |
-
|
154 |
-
F.Prestipino, F.Di Pane Masi, A.Nucita and F.Micali
|
155 |
|
156 |
== Installation ==
|
157 |
|
158 |
Installation and Configuration are very simple :
|
159 |
|
160 |
-
1. After you have installed and activated the plugin , go to Settings
|
161 |
-
2. To add shortcode to editor click on the
|
162 |
3. Configure the display of your shortcodes from the plugin settings page
|
163 |
-
4. To add to the Sidebar Enjoy
|
164 |
-
|
165 |
|
166 |
== Frequently Asked Questions ==
|
167 |
|
168 |
-
= “Important:
|
169 |
|
170 |
—————
|
171 |
|
172 |
-
= How to Install Enjoy
|
173 |
[https://www.mediabetaprojects.com/enjoy-instagram-premium/install-enjoy-instagram-wordpress-plugin/](https://www.mediabetaprojects.com/enjoy-instagram-premium/install-enjoy-instagram-wordpress-plugin/)
|
174 |
|
175 |
|
@@ -178,7 +188,7 @@ Sometimes, when you upgrade the plugin you need also to hook again your Instagra
|
|
178 |
|
179 |
|
180 |
= Where can i find ShortCodes ? =
|
181 |
-
The shortcodes are automatically generated by clicking the “Enjoy
|
182 |
If you do not see the button of shortcodes, you can use these shortcodes to:
|
183 |
|
184 |
[enjoyinstagram_mb] -> Instagram Carousel View
|
@@ -189,8 +199,8 @@ In the Setting section yon can customize grid and/or Carousel view
|
|
189 |
|
190 |
== Screenshots ==
|
191 |
|
192 |
-
1. Enjoy
|
193 |
-
2. Enjoy
|
194 |
3. Your Instagram Profile
|
195 |
4. Control Panel for Grid View and Carousel View Settings
|
196 |
5. Front End View Example
|
@@ -200,6 +210,8 @@ In the Setting section yon can customize grid and/or Carousel view
|
|
200 |
|
201 |
== Changelog ==
|
202 |
|
|
|
|
|
203 |
= 4.0.7 =
|
204 |
* Removed useless param scope from authorization url
|
205 |
= 4.0.6 =
|
@@ -228,19 +240,19 @@ In the Setting section yon can customize grid and/or Carousel view
|
|
228 |
= 3.4.2 =
|
229 |
* Bug Fix
|
230 |
= 3.4.1 =
|
231 |
-
* NB: Enjoy
|
232 |
= 3.4 =
|
233 |
* Bux fixing: Instagram feed on website Wordpress full compatibility with DIVI theme
|
234 |
= 3.3 =
|
235 |
* New: Video Instagram feed visualization for browser supporting HTML5
|
236 |
* Fixed: Minor issues
|
237 |
= 3.2 =
|
238 |
-
* New: Enjoy
|
239 |
* Fixed: Minor issues
|
240 |
= 3.1 =
|
241 |
* Fixed: Minor issues
|
242 |
= 3.0 =
|
243 |
-
* New: Enjoy
|
244 |
= 2.1.3 =
|
245 |
* Add Shortcakes Info
|
246 |
= 2.1.2 =
|
@@ -282,4 +294,4 @@ In the Setting section yon can customize grid and/or Carousel view
|
|
282 |
= 1.01 =
|
283 |
* Bux Fix
|
284 |
= 1.0 =
|
285 |
-
* Initial Version of Enjoy
|
1 |
+
=== Enjoy Social media feed pictures with Widget and Shortcode on Wordpress website ===
|
2 |
Contributors: mediabeta
|
3 |
Donate link: https://www.google.com/url?q=https%3A%2F%2Fwww.paypal.com%2Fcgi-bin%2Fwebscr%3Fcmd%3D_s-xclick%26hosted_button_id%3D8MXZ37DWHAX46&sa=D&sntz=1&usg=AFQjCNFHixLdowdc2AAEXDYmM9tQBl-TXQ
|
4 |
Tags: Instagram, Instagram feed, Instagram Widget, Instagram grid, Instagram carousel, Embed Instagram, Embed Instagram feed, Instagram feed on website, responsive carousel, WordPress carousel, Instagram gallery, Instagram WordPress, Instagram pictures
|
5 |
Requires at least: 4.0
|
6 |
+
Tested up to: 5.4
|
7 |
+
Version: 5.0
|
8 |
+
Stable tag: 5.0
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
12 |
+
Formerly “Enjoy Instagram Feed”. Social media feed pictures for your website by hashtag and Instagram account. Widget and shortcodes on posts, pages, sidebar.
|
13 |
|
14 |
== Description ==
|
15 |
|
16 |
+
= Add Instagram feed on website by hashtag and public Instagram account with carousel and grid view using simple shortcodes. =
|
17 |
|
18 |
+
== Important ==
|
19 |
+
Instagram is changing its API. Our plugin has already moved to the new stable Instagram API: Basic Display API for Personal account and Graph API for Business account.
|
20 |
+
|
21 |
+
= To allow your Instagram feeds to work best, we suggest you to install the latest version of our plugin. =
|
22 |
+
|
23 |
+
To make your shortcodes work again, download the last version, disconnect and then reconnect your Instagram account (from the "settings" page) in order to keep your Enjoy Plugin Instagram functioning.
|
24 |
+
|
25 |
+
== ENJOY PLUGIN FOR SOCIAL MEDIA FEED PICTURES FEATURES ==
|
26 |
+
|
27 |
+
Only one plugin to publish Instagram feed on your pages, posts and sidebars with widgets and shortcodes.
|
28 |
Each Instagram photo can be shown in Carousel and Grid mode with Lightbox effect.
|
29 |
+
Enjoy plugin for social media feed pictures is responsive and optimized for mobile devices.
|
30 |
|
31 |
+
Once you have installed our plugin Enjoy plugin for social media feed pictures, thanks to the presence of the icon on the editor, you are able to use shortcodes to embed feed in just one single line.
|
32 |
|
33 |
+
= Here is Live Demo for Enjoy plugin for social media feed pictures: = [http://www.mediabetaprojects.com/enjoy-instagram-premium/instagram-feeds-in-your-website-enjoy-instagram-free/](http://www.mediabetaprojects.com/enjoy-instagram-premium/instagram-feeds-in-your-website-enjoy-instagram-free/)
|
34 |
|
35 |
+
= Enjoy Plugin for social media feed pictures basic allows Instagram video visualization for browser supporting HTML5 =
|
36 |
|
37 |
+
== BASIC FEATURES ==
|
38 |
|
39 |
+
* NEW —> Display Instagram feeds for Personal or Business Instagram account
|
40 |
+
* NEW —> Hashtag-based Instagram feed to show photos by Instagram hashtag, also public hashtag
|
41 |
* Profile-based Instagram feed to show photos by Instagram profiles
|
|
|
42 |
* Instagram Widget for sidebars to publish Instagram feed with carousel and grid visualization
|
43 |
* Instagram Carousel feed and Instagram Grid feed to add with Shortcode
|
44 |
* Shortcode button in the editor page and post
|
45 |
|
46 |
|
47 |
* Pictures Transition for carousel: one picture / more pictures at a time
|
48 |
+
* Option for activating Navigation in Carousel view (yes/no)
|
49 |
* Customization for Number of Instagram pictures to see in the same time
|
50 |
|
51 |
* Number of columns and rows customizable
|
62 |
* One click set up.
|
63 |
* Php 7 compatible
|
64 |
|
65 |
+
= Very Simple Installation and Configuration for Enjoy Plugin for social media feed pictures =
|
66 |
|
67 |
[http://www.mediabetaprojects.com/enjoy-instagram-premium/install-enjoy-instagram-wordpress-plugin/](http://www.mediabetaprojects.com/enjoy-instagram-premium/install-enjoy-instagram-wordpress-plugin/)
|
68 |
|
69 |
+
= Enjoy Plugin for social media feed pictures PREMIUM VERSION =
|
70 |
|
71 |
+
Enjoy Plugin for social media feed pictures is the only Wordpress plugin with a MODERATION PANEL which allows you to display or not the images in the pages, posts and sidebars.
|
72 |
The last plugin version now supports multi hashtags and profiles, pictures with square format, grid view with a border between pictures.
|
73 |
|
74 |
|
75 |
+
== PREMIUM FEATURES in Enjoy Plugin for social media feed pictures ==
|
76 |
|
77 |
* More shortcodes in the same page or post to display multiple instagram feeds
|
78 |
* More shortcodes for different hashtags or profiles in the same page or post
|
85 |
* Instagram Carousel, Instagram Grid, Instagram Polaroid, Instagram Album and Badge view
|
86 |
* On click, Pictures of different views can be redirected to Instagram page, to a particular website or opened in a Lightbox
|
87 |
* The Lightbox displays Instagram pictures as a slideshow with media caption
|
88 |
+
|
89 |
+
* MODERATION PANEL to approve or reject, in real time, some pictures on your Instagram Feed
|
90 |
+
|
91 |
* NEW - Performance improved
|
92 |
* NEW - Cleaned and optimizated code
|
93 |
* NEW - Improved css and js loading
|
100 |
* to Show Likes Count
|
101 |
* to Show author
|
102 |
|
103 |
+
<strong>INSTAGRAM WIDGET FEATURE</strong>
|
104 |
+
Instagram Widget is one feature of Enjoy plugin for social media feed pictures.
|
105 |
Once you installed it, you will be able to use Carousel and Grid widget in the dedicated Section.
|
106 |
|
107 |
+
You will have only to drag the widget in the sidebar you want to customize. To arrange the Widget within the Sidebar, click, drag and drop the widget in the order you want.
|
108 |
[DEMO for Instagram Widget on website WordPress](https://www.mediabetaprojects.com/enjoy-instagram-premium/widget-instagram-on-your-website-how-to/)
|
109 |
|
110 |
+
= FOR INSTAGRAM CAROUSEL SHORTCODE you can set: =
|
111 |
* images displayed at a time
|
112 |
* animation in / animation out
|
113 |
* show different number of images for different screen resolution
|
116 |
|
117 |
[DEMO for Instagram Carousel feed on website WordPress](https://www.mediabetaprojects.com/enjoy-instagram-premium/carousel-view-instagram-wordpress-plugin/)
|
118 |
|
119 |
+
= FOR INSTAGRAM GRID SHORTCODE you can set: =
|
120 |
* the number of rows and columns for the different shortcodes
|
121 |
* the number of images that are replaced at the same time
|
122 |
* interval the images will be replaced
|
125 |
|
126 |
[DEMO for Instagram Grid feed on website WordPress](https://www.mediabetaprojects.com/enjoy-instagram-premium/grid-view-instagram-plugin/)
|
127 |
|
128 |
+
= FOR INSTAGRAM POLAROID SHORTCODE you can set: =
|
129 |
* to show info (caption) on back
|
130 |
* color background, border width, border color
|
131 |
|
142 |
= See LIVE PREVIEW: =
|
143 |
[http://www.mediabetaprojects.com/enjoy-instagram-premium/](http://www.mediabetaprojects.com/enjoy-instagram-premium/)
|
144 |
|
145 |
+
= OTHER FEATURES: =
|
146 |
|
147 |
* Instagram Album View to show your pictures organized for Instagram username and or Instagram hashtags
|
148 |
* Instagram Badge View that will help you link to and promote your Instagram web profile
|
149 |
* Autoreload Stream of Instagram Photos
|
150 |
+
* MODERATION PANEL: In real time you can moderate new Instagram photos and decide to approve and to publish or to rejected (Watch how it works:
|
151 |
[youtube https://www.youtube.com/watch?v=W6gNqlghbLE]
|
152 |
* Autoplay
|
153 |
* Loop
|
159 |
|
160 |
and many others features..
|
161 |
|
162 |
+
= LIVE PREMIUM VERSION DEMO for Enjoy Plugin for social media feed pictures: =
|
163 |
[http://www.mediabetaprojects.com/enjoy-instagram-premium/](http://www.mediabetaprojects.com/enjoy-instagram-premium/)
|
164 |
|
165 |
+
|
|
|
166 |
|
167 |
== Installation ==
|
168 |
|
169 |
Installation and Configuration are very simple :
|
170 |
|
171 |
+
1. After you have installed and activated the plugin , go to Settings and follow the instructions on the screen.
|
172 |
+
2. To add shortcode to editor click on the plugin icon and choose where include a Carousel View or a Grid View.
|
173 |
3. Configure the display of your shortcodes from the plugin settings page
|
174 |
+
4. To add to the Sidebar Enjoy plugin for social media feed pictures go to Appearance - > Widgets and configure.
|
|
|
175 |
|
176 |
== Frequently Asked Questions ==
|
177 |
|
178 |
+
= “Important: Instagram is changing its APIs and access to its old ones it will be, permanently, blocked on June 29, 2020.” =
|
179 |
|
180 |
—————
|
181 |
|
182 |
+
= How to Install Enjoy plugin for social media feed pictures on your WordPress Website =
|
183 |
[https://www.mediabetaprojects.com/enjoy-instagram-premium/install-enjoy-instagram-wordpress-plugin/](https://www.mediabetaprojects.com/enjoy-instagram-premium/install-enjoy-instagram-wordpress-plugin/)
|
184 |
|
185 |
|
188 |
|
189 |
|
190 |
= Where can i find ShortCodes ? =
|
191 |
+
The shortcodes are automatically generated by clicking the “Enjoy Button” that you can see on text editor of posts and pages.
|
192 |
If you do not see the button of shortcodes, you can use these shortcodes to:
|
193 |
|
194 |
[enjoyinstagram_mb] -> Instagram Carousel View
|
199 |
|
200 |
== Screenshots ==
|
201 |
|
202 |
+
1. Enjoy Plugin for social media feed pictures settings page
|
203 |
+
2. Enjoy Plugin for social media feed pictures settings page2
|
204 |
3. Your Instagram Profile
|
205 |
4. Control Panel for Grid View and Carousel View Settings
|
206 |
5. Front End View Example
|
210 |
|
211 |
== Changelog ==
|
212 |
|
213 |
+
= 5.0 =
|
214 |
+
* Compatibility with the new Instagram API's: Basic Display API and Graph API
|
215 |
= 4.0.7 =
|
216 |
* Removed useless param scope from authorization url
|
217 |
= 4.0.6 =
|
240 |
= 3.4.2 =
|
241 |
* Bug Fix
|
242 |
= 3.4.1 =
|
243 |
+
* NB: Enjoy plugin for social media feed pictures feed on website Wordpress is Php 7 compatible
|
244 |
= 3.4 =
|
245 |
* Bux fixing: Instagram feed on website Wordpress full compatibility with DIVI theme
|
246 |
= 3.3 =
|
247 |
* New: Video Instagram feed visualization for browser supporting HTML5
|
248 |
* Fixed: Minor issues
|
249 |
= 3.2 =
|
250 |
+
* New: Enjoy plugin for social media feed pictures with squared format supported
|
251 |
* Fixed: Minor issues
|
252 |
= 3.1 =
|
253 |
* Fixed: Minor issues
|
254 |
= 3.0 =
|
255 |
+
* New: Enjoy plugin for social media feed pictures on website full compatible with New Instagram Api Implementation
|
256 |
= 2.1.3 =
|
257 |
* Add Shortcakes Info
|
258 |
= 2.1.2 =
|
294 |
= 1.01 =
|
295 |
* Bux Fix
|
296 |
= 1.0 =
|
297 |
+
* Initial Version of Enjoy plugin for social media feed pictures feed on website
|
templates/admin/enjoyinstagram-advanced-settings.php
CHANGED
@@ -3,27 +3,35 @@
|
|
3 |
* Appearance settings template
|
4 |
*/
|
5 |
|
6 |
-
if (!defined('ABSPATH')) {
|
7 |
-
|
8 |
}
|
|
|
|
|
|
|
9 |
?>
|
10 |
|
11 |
<form method="post" action="options.php" novalidate>
|
12 |
-
|
13 |
|
14 |
<script type="text/javascript">
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
});
|
|
|
27 |
</script>
|
28 |
|
29 |
<table class="form-table">
|
@@ -31,37 +39,59 @@ if (!defined('ABSPATH')) {
|
|
31 |
<tr valign="top">
|
32 |
<th scope="row" style="align:left;">
|
33 |
<span class="highlighted">
|
34 |
-
<?php _e('Inclusion mode',
|
|
|
35 |
</span>
|
36 |
</th>
|
37 |
<td>
|
38 |
<div class="ei_block">
|
39 |
<div class="ei_settings_float_block">
|
40 |
-
|
41 |
</div>
|
42 |
<div class="ei_settings_float_block">
|
43 |
<input type="radio"
|
44 |
-
name="enjoyinstagram_user_or_hashtag" <?php checked('user',
|
|
|
45 |
value="user">
|
46 |
-
|
|
|
47 |
<input type="radio"
|
48 |
-
name="enjoyinstagram_user_or_hashtag" <?php checked('hashtag',
|
|
|
49 |
value="hashtag">
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
</div>
|
52 |
<div class="ei_settings_float_block">
|
53 |
<div id="enjoyinstagram_user_or_hashtag_user"
|
54 |
-
class="desc" <?php if (get_option('enjoyinstagram_user_or_hashtag',
|
|
|
|
|
|
|
55 |
<input type="text" class="ei_disabled" id="enjoyinstagram_user" disabled
|
56 |
-
value="<?php echo get_option('enjoyinstagram_user_username'); ?>"
|
57 |
name="enjoyinstagram_user"/>
|
58 |
</div>
|
59 |
<div id="enjoyinstagram_user_or_hashtag_hashtag"
|
60 |
-
class="desc" <?php if (get_option('enjoyinstagram_user_or_hashtag', 'user'
|
|
|
|
|
|
|
61 |
#<input type="text" id="enjoyinstagram_hashtag" required
|
62 |
-
value="<?php echo get_option('enjoyinstagram_hashtag'); ?>"
|
63 |
name="enjoyinstagram_hashtag"/>
|
64 |
-
<span class="description"><?php _ex("insert a hashtag without '#'", 'option description',
|
|
|
65 |
</div>
|
66 |
</div>
|
67 |
</div>
|
@@ -77,41 +107,48 @@ if (!defined('ABSPATH')) {
|
|
77 |
<tr valign="top">
|
78 |
<th scope="row" style="align:left;">
|
79 |
<span class="highlighted">
|
80 |
-
<?php _e('Carousel settings',
|
|
|
81 |
</span>
|
82 |
</th>
|
83 |
<td>
|
84 |
<div class="ei_block">
|
85 |
<div class="ei_settings_float_block ei_fixed">
|
86 |
<label for="enjoyinstagram_carousel_items_number">
|
87 |
-
|
|
|
88 |
</label>
|
89 |
</div>
|
90 |
<div class="ei_settings_float_block">
|
91 |
<select name="enjoyinstagram_carousel_items_number" class="ei_sel"
|
92 |
id="enjoyinstagram_carousel_items_number">
|
93 |
-
|
94 |
-
<option value="<?php echo $i ?>" <?php selected($i,
|
95 |
-
|
|
|
96 |
</option>
|
97 |
-
|
98 |
</select>
|
99 |
</div>
|
100 |
</div>
|
101 |
<div class="ei_block">
|
102 |
<div class="ei_settings_float_block ei_fixed">
|
103 |
<label for="enjoyinstagram_carousel_navigation">
|
104 |
-
|
|
|
105 |
</label>
|
106 |
</div>
|
107 |
<div class="ei_settings_float_block">
|
108 |
<select name="enjoyinstagram_carousel_navigation" class="ei_sel"
|
109 |
id="enjoyinstagram_carousel_navigation">
|
110 |
-
<option value="true" <?php selected('true',
|
111 |
-
|
|
|
|
|
112 |
</option>
|
113 |
-
<option value="false" <?php selected('false',
|
114 |
-
|
|
|
115 |
</option>
|
116 |
</select>
|
117 |
</div>
|
@@ -127,23 +164,26 @@ if (!defined('ABSPATH')) {
|
|
127 |
<tr valign="top">
|
128 |
<th scope="row" style="align:left;">
|
129 |
<span class="highlighted">
|
130 |
-
<?php _e('Grid view settings',
|
|
|
131 |
</span>
|
132 |
</th>
|
133 |
<td>
|
134 |
<div class="ei_block">
|
135 |
<div class="ei_settings_float_block ei_fixed">
|
136 |
<label for="enjoyinstagram_grid_cols">
|
137 |
-
|
|
|
138 |
</label>
|
139 |
</div>
|
140 |
<div class="ei_settings_float_block">
|
141 |
<select name="enjoyinstagram_grid_cols" id="enjoyinstagram_grid_cols" class="ei_sel">
|
142 |
-
|
143 |
-
<option value="<?php echo $i ?>" <?php selected($i,
|
144 |
-
|
|
|
145 |
</option>
|
146 |
-
|
147 |
</select>
|
148 |
</div>
|
149 |
</div>
|
@@ -151,16 +191,18 @@ if (!defined('ABSPATH')) {
|
|
151 |
<div class="ei_block">
|
152 |
<div class="ei_settings_float_block ei_fixed">
|
153 |
<label for="enjoyinstagram_grid_rows">
|
154 |
-
|
|
|
155 |
</label>
|
156 |
</div>
|
157 |
<div class="ei_settings_float_block">
|
158 |
<select name="enjoyinstagram_grid_rows" id="enjoyinstagram_grid_rows" class="ei_sel">
|
159 |
-
|
160 |
-
<option value="<?php echo $i ?>" <?php selected($i,
|
161 |
-
|
|
|
162 |
</option>
|
163 |
-
|
164 |
</select>
|
165 |
</div>
|
166 |
</div>
|
@@ -170,11 +212,12 @@ if (!defined('ABSPATH')) {
|
|
170 |
</table>
|
171 |
<hr/>
|
172 |
<p>
|
173 |
-
|
|
|
174 |
</p>
|
175 |
<input type="submit" class="button-primary" id="button_enjoyinstagram_advanced"
|
176 |
name="button_enjoyinstagram_advanced"
|
177 |
-
value="<?php _e('Save Settings', 'enjoy-instagram-instagram-responsive-images-gallery-and-carousel'); ?>">
|
178 |
</form>
|
179 |
<div class="wrap" style="
|
180 |
float: left;
|
@@ -183,8 +226,10 @@ if (!defined('ABSPATH')) {
|
|
183 |
padding: 20px;
|
184 |
margin-top: 20px;
|
185 |
border: 2px solid green;">
|
186 |
-
<h3><?php _e('Shortocodes to use', 'enjoy-instagram-instagram-responsive-images-gallery-and-carousel'); ?>:</h3>
|
187 |
-
|
188 |
-
|
|
|
|
|
189 |
</div>
|
190 |
|
3 |
* Appearance settings template
|
4 |
*/
|
5 |
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // return if called directly
|
8 |
}
|
9 |
+
|
10 |
+
$user = EnjoyInstagram()->get_selected_user();
|
11 |
+
|
12 |
?>
|
13 |
|
14 |
<form method="post" action="options.php" novalidate>
|
15 |
+
<?php settings_fields( 'enjoyinstagram_options_carousel_group' ); ?>
|
16 |
|
17 |
<script type="text/javascript">
|
18 |
+
jQuery(document).ready(function ($) {
|
19 |
+
$("input[name$='enjoyinstagram_user_or_hashtag']").click(function () {
|
20 |
+
var test = $(this).val();
|
21 |
+
|
22 |
+
if (test === 'public_hashtag') {
|
23 |
+
test = 'hashtag';
|
24 |
+
}
|
25 |
+
|
26 |
+
if (test === 'user') {
|
27 |
+
$('#enjoyinstagram_hashtag').attr('disabled', true);
|
28 |
+
} else if (test === 'hashtag') {
|
29 |
+
$('#enjoyinstagram_hashtag').attr('disabled', false);
|
30 |
+
}
|
31 |
+
$("div.desc").hide();
|
32 |
+
$("#enjoyinstagram_user_or_hashtag_" + test).show();
|
33 |
});
|
34 |
+
});
|
35 |
</script>
|
36 |
|
37 |
<table class="form-table">
|
39 |
<tr valign="top">
|
40 |
<th scope="row" style="align:left;">
|
41 |
<span class="highlighted">
|
42 |
+
<?php _e( 'Inclusion mode',
|
43 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?>:
|
44 |
</span>
|
45 |
</th>
|
46 |
<td>
|
47 |
<div class="ei_block">
|
48 |
<div class="ei_settings_float_block">
|
49 |
+
<?php _e( 'Show pics', 'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?>:
|
50 |
</div>
|
51 |
<div class="ei_settings_float_block">
|
52 |
<input type="radio"
|
53 |
+
name="enjoyinstagram_user_or_hashtag" <?php checked( 'user',
|
54 |
+
get_option( 'enjoyinstagram_user_or_hashtag', 'user' ) ) ?>
|
55 |
value="user">
|
56 |
+
<?php _ex( 'of Your Profile', 'option label',
|
57 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?><br/><br/>
|
58 |
<input type="radio"
|
59 |
+
name="enjoyinstagram_user_or_hashtag" <?php checked( 'hashtag',
|
60 |
+
get_option( 'enjoyinstagram_user_or_hashtag', 'user' ) ) ?>
|
61 |
value="hashtag">
|
62 |
+
<?php _ex( 'by Hashtag', 'option label',
|
63 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?><br/>
|
64 |
+
|
65 |
+
<?php if ( $user !== false && $user['business'] ): ?>
|
66 |
+
<br/>
|
67 |
+
<input type="radio"
|
68 |
+
name="enjoyinstagram_user_or_hashtag" <?php checked( 'public_hashtag',
|
69 |
+
get_option( 'enjoyinstagram_user_or_hashtag', 'user' ) ) ?>
|
70 |
+
value="public_hashtag">
|
71 |
+
<?php _ex( 'by Public Hashtag', 'option label',
|
72 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?><br/>
|
73 |
+
<?php endif ?>
|
74 |
</div>
|
75 |
<div class="ei_settings_float_block">
|
76 |
<div id="enjoyinstagram_user_or_hashtag_user"
|
77 |
+
class="desc" <?php if ( get_option( 'enjoyinstagram_user_or_hashtag',
|
78 |
+
'user' ) != 'user' ) {
|
79 |
+
echo 'style="display:none;"';
|
80 |
+
} ?>>
|
81 |
<input type="text" class="ei_disabled" id="enjoyinstagram_user" disabled
|
82 |
+
value="<?php echo get_option( 'enjoyinstagram_user_username' ); ?>"
|
83 |
name="enjoyinstagram_user"/>
|
84 |
</div>
|
85 |
<div id="enjoyinstagram_user_or_hashtag_hashtag"
|
86 |
+
class="desc" <?php if ( strpos( get_option( 'enjoyinstagram_user_or_hashtag', 'user' ),
|
87 |
+
'hashtag' ) === false ) {
|
88 |
+
echo 'style="display:none;"';
|
89 |
+
} ?>>
|
90 |
#<input type="text" id="enjoyinstagram_hashtag" required
|
91 |
+
value="<?php echo get_option( 'enjoyinstagram_hashtag' ); ?>"
|
92 |
name="enjoyinstagram_hashtag"/>
|
93 |
+
<span class="description"><?php _ex( "insert a hashtag without '#'", 'option description',
|
94 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?></span>
|
95 |
</div>
|
96 |
</div>
|
97 |
</div>
|
107 |
<tr valign="top">
|
108 |
<th scope="row" style="align:left;">
|
109 |
<span class="highlighted">
|
110 |
+
<?php _e( 'Carousel settings',
|
111 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?>:
|
112 |
</span>
|
113 |
</th>
|
114 |
<td>
|
115 |
<div class="ei_block">
|
116 |
<div class="ei_settings_float_block ei_fixed">
|
117 |
<label for="enjoyinstagram_carousel_items_number">
|
118 |
+
<?php _ex( 'Images displayed at a time', 'option label',
|
119 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?>:
|
120 |
</label>
|
121 |
</div>
|
122 |
<div class="ei_settings_float_block">
|
123 |
<select name="enjoyinstagram_carousel_items_number" class="ei_sel"
|
124 |
id="enjoyinstagram_carousel_items_number">
|
125 |
+
<?php for ( $i = 1; $i <= 10; $i ++ ): ?>
|
126 |
+
<option value="<?php echo $i ?>" <?php selected( $i,
|
127 |
+
get_option( 'enjoyinstagram_carousel_items_number', '4' ) ); ?>>
|
128 |
+
<?php echo " " . $i; ?>
|
129 |
</option>
|
130 |
+
<?php endfor; ?>
|
131 |
</select>
|
132 |
</div>
|
133 |
</div>
|
134 |
<div class="ei_block">
|
135 |
<div class="ei_settings_float_block ei_fixed">
|
136 |
<label for="enjoyinstagram_carousel_navigation">
|
137 |
+
<?php _ex( 'Navigation buttons', 'option label',
|
138 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?>:
|
139 |
</label>
|
140 |
</div>
|
141 |
<div class="ei_settings_float_block">
|
142 |
<select name="enjoyinstagram_carousel_navigation" class="ei_sel"
|
143 |
id="enjoyinstagram_carousel_navigation">
|
144 |
+
<option value="true" <?php selected( 'true',
|
145 |
+
get_option( 'enjoyinstagram_carousel_navigation', 'false' ) ); ?>>
|
146 |
+
<?php _e( 'Yes',
|
147 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?>
|
148 |
</option>
|
149 |
+
<option value="false" <?php selected( 'false',
|
150 |
+
get_option( 'enjoyinstagram_carousel_navigation', 'false' ) ); ?>>
|
151 |
+
<?php _e( 'No', 'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?>
|
152 |
</option>
|
153 |
</select>
|
154 |
</div>
|
164 |
<tr valign="top">
|
165 |
<th scope="row" style="align:left;">
|
166 |
<span class="highlighted">
|
167 |
+
<?php _e( 'Grid view settings',
|
168 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?>:
|
169 |
</span>
|
170 |
</th>
|
171 |
<td>
|
172 |
<div class="ei_block">
|
173 |
<div class="ei_settings_float_block ei_fixed">
|
174 |
<label for="enjoyinstagram_grid_cols">
|
175 |
+
<?php _ex( 'Number of Columns', 'option label',
|
176 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?>:
|
177 |
</label>
|
178 |
</div>
|
179 |
<div class="ei_settings_float_block">
|
180 |
<select name="enjoyinstagram_grid_cols" id="enjoyinstagram_grid_cols" class="ei_sel">
|
181 |
+
<?php for ( $i = 1; $i <= 10; $i ++ ) : ?>
|
182 |
+
<option value="<?php echo $i ?>" <?php selected( $i,
|
183 |
+
get_option( 'enjoyinstagram_grid_cols', '5' ) ); ?>>
|
184 |
+
<?php echo " " . $i; ?>
|
185 |
</option>
|
186 |
+
<?php endfor; ?>
|
187 |
</select>
|
188 |
</div>
|
189 |
</div>
|
191 |
<div class="ei_block">
|
192 |
<div class="ei_settings_float_block ei_fixed">
|
193 |
<label for="enjoyinstagram_grid_rows">
|
194 |
+
<?php _ex( 'Number of Rows', 'option label',
|
195 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?>:
|
196 |
</label>
|
197 |
</div>
|
198 |
<div class="ei_settings_float_block">
|
199 |
<select name="enjoyinstagram_grid_rows" id="enjoyinstagram_grid_rows" class="ei_sel">
|
200 |
+
<?php for ( $i = 1; $i <= 10; $i ++ ) : ?>
|
201 |
+
<option value="<?php echo $i ?>" <?php selected( $i,
|
202 |
+
get_option( 'enjoyinstagram_grid_rows', '2' ) ); ?>>
|
203 |
+
<?php echo " " . $i; ?>
|
204 |
</option>
|
205 |
+
<?php endfor; ?>
|
206 |
</select>
|
207 |
</div>
|
208 |
</div>
|
212 |
</table>
|
213 |
<hr/>
|
214 |
<p>
|
215 |
+
<?php _e( '<strong>Free version</strong>: Only 20 images allowed.',
|
216 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?>
|
217 |
</p>
|
218 |
<input type="submit" class="button-primary" id="button_enjoyinstagram_advanced"
|
219 |
name="button_enjoyinstagram_advanced"
|
220 |
+
value="<?php _e( 'Save Settings', 'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?>">
|
221 |
</form>
|
222 |
<div class="wrap" style="
|
223 |
float: left;
|
226 |
padding: 20px;
|
227 |
margin-top: 20px;
|
228 |
border: 2px solid green;">
|
229 |
+
<h3><?php _e( 'Shortocodes to use', 'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?>:</h3>
|
230 |
+
[enjoyinstagram_mb] » <?php _e( 'Carousel View',
|
231 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?><br/>
|
232 |
+
[enjoyinstagram_mb_grid] » <?php _e( 'Grid View',
|
233 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?>
|
234 |
</div>
|
235 |
|
templates/admin/enjoyinstagram-general-settings.php
CHANGED
@@ -3,31 +3,40 @@
|
|
3 |
* Users settings template
|
4 |
*/
|
5 |
|
6 |
-
if (!defined('ABSPATH')) {
|
7 |
-
|
8 |
}
|
9 |
|
10 |
-
$
|
11 |
|
12 |
-
if ($
|
13 |
<div>
|
14 |
-
<h2><?php _e('Your Instagram Profile',
|
|
|
15 |
<hr/>
|
16 |
|
17 |
<div id="enjoy_user_profile">
|
18 |
-
|
|
|
|
|
19 |
<form method="post">
|
20 |
<input type="hidden" name="action" value="enjoyinstagram_remove_user">
|
21 |
<input type="submit" id="button_logout"
|
22 |
-
value="<?php _e( 'Unlink Profile',
|
|
|
|
|
23 |
</form>
|
24 |
</div>
|
25 |
|
26 |
<div id="enjoy_user_block">
|
27 |
-
<h3><?php echo
|
28 |
-
|
|
|
|
|
29 |
<hr/>
|
30 |
-
|
|
|
|
|
31 |
<hr/>
|
32 |
</div>
|
33 |
</div>
|
@@ -38,22 +47,48 @@ if ($user_token) : ?>
|
|
38 |
padding: 20px;
|
39 |
margin-top: 20px;
|
40 |
border: 2px solid green;">
|
41 |
-
<h3><?php _e('Shortocodes to use', 'enjoy-instagram-instagram-responsive-images-gallery-and-carousel');
|
42 |
-
|
43 |
-
<b>[
|
|
|
|
|
|
|
44 |
</div>
|
45 |
|
46 |
<?php else : ?>
|
47 |
|
48 |
-
<p
|
49 |
-
|
|
|
|
|
50 |
</p>
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
</p>
|
54 |
|
55 |
-
<a href="<?php echo EnjoyInstagram_Admin()->
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
</a>
|
|
|
|
|
|
|
58 |
|
59 |
<?php endif; ?>
|
3 |
* Users settings template
|
4 |
*/
|
5 |
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // return if called directly
|
8 |
}
|
9 |
|
10 |
+
$user = EnjoyInstagram()->get_selected_user();
|
11 |
|
12 |
+
if ( $user ) : ?>
|
13 |
<div>
|
14 |
+
<h2><?php _e( 'Your Instagram Profile',
|
15 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?></h2>
|
16 |
<hr/>
|
17 |
|
18 |
<div id="enjoy_user_profile">
|
19 |
+
<?php if ( $user['business'] ): ?>
|
20 |
+
<img class="enjoy_user_profile" src="<?php echo $user['profile_picture']; ?>">
|
21 |
+
<?php endif; ?>
|
22 |
<form method="post">
|
23 |
<input type="hidden" name="action" value="enjoyinstagram_remove_user">
|
24 |
<input type="submit" id="button_logout"
|
25 |
+
value="<?php _e( 'Unlink Profile',
|
26 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?>"
|
27 |
+
class="button-primary ei_top"/>
|
28 |
</form>
|
29 |
</div>
|
30 |
|
31 |
<div id="enjoy_user_block">
|
32 |
+
<h3><?php echo $user['username'] ?></h3>
|
33 |
+
<?php if ( $user['business'] ): ?>
|
34 |
+
<p><i><?php echo $user['bio']; ?></i></p>
|
35 |
+
<?php endif ?>
|
36 |
<hr/>
|
37 |
+
<?php printf( __( 'Customize the plugin with our <a href="%s">settings</a> tab.',
|
38 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ),
|
39 |
+
EnjoyInstagram_Admin()->get_tab_url( 'enjoyinstagram_advanced_settings' ) ); ?>
|
40 |
<hr/>
|
41 |
</div>
|
42 |
</div>
|
47 |
padding: 20px;
|
48 |
margin-top: 20px;
|
49 |
border: 2px solid green;">
|
50 |
+
<h3><?php _e( 'Shortocodes to use', 'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?>
|
51 |
+
:</h3>
|
52 |
+
<b>[enjoyinstagram_mb]</b> -> <?php _e( 'Carousel View',
|
53 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?><br/>
|
54 |
+
<b>[enjoyinstagram_mb_grid]</b> -> <?php _e( 'Grid View',
|
55 |
+
'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?>
|
56 |
</div>
|
57 |
|
58 |
<?php else : ?>
|
59 |
|
60 |
+
<p>
|
61 |
+
<?php _e( 'Thank you for you choise! <strong>Enjoy Instagram - Responsive gallery</strong> is a plugin lovingly developed for you by ',
|
62 |
+
'enjoyinstagram' ); ?>
|
63 |
+
<a href="http://www.mediabeta.com" target="_blank">Mediabeta</a>.
|
64 |
</p>
|
65 |
+
|
66 |
+
<p>
|
67 |
+
By using this plugin, you are agreeing to the <a href="http://instagram.com/about/legal/terms/api/"
|
68 |
+
target="_blank">Instagram API Terms of Use</a>.
|
69 |
+
</p>
|
70 |
+
|
71 |
+
<p>
|
72 |
+
<?php _e( 'If you are a Business Instagram account connect to Facebook Graph API using the button below to get latest API features and hashtag search',
|
73 |
+
'enjoyinstagram' ); ?>
|
74 |
</p>
|
75 |
|
76 |
+
<a href="<?php echo EnjoyInstagram_Admin()->get_facebook_connect_url() ?>" class="button-primary">
|
77 |
+
<?php _e( 'Add new user - Business Instagram Account', 'enjoyinstagram' ) ?>
|
78 |
+
</a>
|
79 |
+
|
80 |
+
<a href="#" class="enjoy-instagram-help"
|
81 |
+
title="<?php _e( 'Business accounts have access to everything from basic profile with full name, bio, website, following count, followers count, profile picture, feed of posts and hashtag feed',
|
82 |
+
'enjoyinstagram' ) ?>">[?]</a>
|
83 |
+
<p>
|
84 |
+
<?php _e( 'Click the button below to connect a standard Instagram account',
|
85 |
+
'enjoyinstagram' ) ?>
|
86 |
+
</p>
|
87 |
+
<a href="<?php echo EnjoyInstagram_Admin()->get_instagram_login_url() ?>" class="button-secondary">
|
88 |
+
<?php _e( 'Add new user - Personal Instagram Account', 'enjoyinstagram' ); ?>
|
89 |
</a>
|
90 |
+
<a href="#" class="enjoy-instagram-help"
|
91 |
+
title="<?php _e( 'Personal accounts have access to profile info such as username, media count, user id and feed of posts',
|
92 |
+
'enjoyinstagram' ) ?>">[?]</a>
|
93 |
|
94 |
<?php endif; ?>
|
templates/admin/settings.php
CHANGED
@@ -40,10 +40,10 @@ if( ! defined( 'ABSPATH' ) ) {
|
|
40 |
<span class="coffee_title"><?php _e( 'Buy me a coffee!', 'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?></span>
|
41 |
<p><span><?php _e( 'If you liked our work please consider to make a kind donation through Paypal.', 'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?></span></p>
|
42 |
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
|
43 |
-
<input type="hidden" name="cmd" value="_s-xclick"
|
44 |
-
<input type="hidden" name="hosted_button_id" value="
|
45 |
-
<input type="image" src="https://www.paypalobjects.com/en_US/IT/i/btn/btn_donateCC_LG.gif" border="0" name="submit"
|
46 |
-
<img alt="" border="0" src="https://www.
|
47 |
</form>
|
48 |
</div>
|
49 |
</div>
|
40 |
<span class="coffee_title"><?php _e( 'Buy me a coffee!', 'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?></span>
|
41 |
<p><span><?php _e( 'If you liked our work please consider to make a kind donation through Paypal.', 'enjoy-instagram-instagram-responsive-images-gallery-and-carousel' ); ?></span></p>
|
42 |
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
|
43 |
+
<input type="hidden" name="cmd" value="_s-xclick" />
|
44 |
+
<input type="hidden" name="hosted_button_id" value="PAZ58MQY9SVCJ" />
|
45 |
+
<input type="image" src="https://www.paypalobjects.com/en_US/IT/i/btn/btn_donateCC_LG.gif" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" />
|
46 |
+
<img alt="" border="0" src="https://www.paypal.com/en_IT/i/scr/pixel.gif" width="1" height="1" />
|
47 |
</form>
|
48 |
</div>
|
49 |
</div>
|
templates/shortcodes/carousel-widget.php
CHANGED
@@ -3,52 +3,54 @@
|
|
3 |
* Carousel widget shortcode template
|
4 |
*/
|
5 |
|
6 |
-
if( ! defined( 'ABSPATH' ) ) {
|
7 |
-
|
8 |
}
|
9 |
|
10 |
?>
|
11 |
<script>
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
});
|
22 |
-
jQuery(function ($) {
|
23 |
-
$(".swipebox").swipebox({
|
24 |
-
hideBarsDelay: 0
|
25 |
-
});
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
});
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
let it = jQuery("#owl-<?php echo $i; ?>").find('.owl-item a');
|
37 |
-
it.css( 'height', it.first().outerWidth() );
|
38 |
-
}
|
39 |
-
jQuery("#owl-<?php echo "{$id}"; ?>").fadeIn('slow');
|
40 |
-
});
|
41 |
</script>
|
42 |
<div id="owl-<?php echo "{$id}"; ?>" class="owl-example enjoy-instagram-carousel">
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
<div class="box">
|
48 |
<a title="<?php echo $entry['caption']['text'] ?>" rel="gallery_swypebox" class="swipebox"
|
49 |
href="<?php echo $entry['images']['standard_resolution']['url'] ?>" <?php echo $link_style ?>>
|
50 |
-
<img
|
51 |
</a>
|
52 |
</div>
|
53 |
-
|
54 |
</div>
|
3 |
* Carousel widget shortcode template
|
4 |
*/
|
5 |
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit;
|
8 |
}
|
9 |
|
10 |
?>
|
11 |
<script>
|
12 |
+
jQuery(function () {
|
13 |
+
jQuery(document.body)
|
14 |
+
.on('click touchend', '#swipebox-slider .current img', function (e) {
|
15 |
+
jQuery('#swipebox-next').click();
|
16 |
+
return false;
|
17 |
+
})
|
18 |
+
.on('click touchend', '#swipebox-slider .current', function (e) {
|
19 |
+
jQuery('#swipebox-close').trigger('click');
|
20 |
+
});
|
21 |
+
});
|
22 |
+
jQuery(function ($) {
|
23 |
+
$(".swipebox").swipebox({
|
24 |
+
hideBarsDelay: 0
|
25 |
});
|
|
|
|
|
|
|
|
|
26 |
|
27 |
+
});
|
28 |
+
jQuery(document).ready(function () {
|
29 |
+
jQuery("#owl-<?php echo "{$id}"; ?>").owlCarousel({
|
30 |
+
items: <?php echo "{$n}"; ?>,
|
31 |
+
navigation: <?php echo "{$n_y_n}"; ?>,
|
32 |
+
autoPlay: true,
|
33 |
+
afterAction: callback_height
|
34 |
});
|
35 |
+
|
36 |
+
function callback_height() {
|
37 |
+
let it = jQuery("#owl-<?php echo $i; ?>").find('.owl-item a');
|
38 |
+
it.css('height', it.first().outerWidth());
|
39 |
+
}
|
40 |
+
|
41 |
+
jQuery("#owl-<?php echo "{$id}"; ?>").fadeIn('slow');
|
42 |
+
});
|
|
|
|
|
|
|
|
|
|
|
43 |
</script>
|
44 |
<div id="owl-<?php echo "{$id}"; ?>" class="owl-example enjoy-instagram-carousel">
|
45 |
+
<?php foreach ( $result as $entry ) :
|
46 |
+
$url = ( $n > 3 ) ? $entry['images']['thumbnail']['url'] : $entry['images']['standard_resolution']['url'];
|
47 |
+
$link_style = "style=\"background-image: url('{$entry['images']['standard_resolution']['url']}'); background-size: cover; display: block; opacity: 1;\"";
|
48 |
+
?>
|
49 |
<div class="box">
|
50 |
<a title="<?php echo $entry['caption']['text'] ?>" rel="gallery_swypebox" class="swipebox"
|
51 |
href="<?php echo $entry['images']['standard_resolution']['url'] ?>" <?php echo $link_style ?>>
|
52 |
+
<img src="<?php echo $url ?>">
|
53 |
</a>
|
54 |
</div>
|
55 |
+
<?php endforeach; ?>
|
56 |
</div>
|
templates/shortcodes/carousel.php
CHANGED
@@ -50,7 +50,7 @@ if( ! defined( 'ABSPATH' ) ) {
|
|
50 |
<?php foreach( $result as $entry ) :
|
51 |
$link = $entry['images']['standard_resolution']['url'];
|
52 |
$url = ($items_num > 3) ? $entry['images']['thumbnail']['url'] : $entry['images']['standard_resolution']['url'];
|
53 |
-
|
54 |
$link_style = "style=\"background-image: url('{$entry['images']['standard_resolution']['url']}'); background-size: cover; display: block; opacity: 1;\"";
|
55 |
?>
|
56 |
<div class="box">
|
50 |
<?php foreach( $result as $entry ) :
|
51 |
$link = $entry['images']['standard_resolution']['url'];
|
52 |
$url = ($items_num > 3) ? $entry['images']['thumbnail']['url'] : $entry['images']['standard_resolution']['url'];
|
53 |
+
|
54 |
$link_style = "style=\"background-image: url('{$entry['images']['standard_resolution']['url']}'); background-size: cover; display: block; opacity: 1;\"";
|
55 |
?>
|
56 |
<div class="box">
|
templates/shortcodes/grid.php
CHANGED
@@ -3,61 +3,61 @@
|
|
3 |
* Grid shortcode template
|
4 |
*/
|
5 |
|
6 |
-
if( ! defined( 'ABSPATH' ) ) {
|
7 |
-
|
8 |
}
|
9 |
|
10 |
?>
|
11 |
<script type="text/javascript">
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
});
|
45 |
-
|
46 |
-
jQuery('#grid-<?php echo $i; ?>').fadeIn('1000');
|
47 |
});
|
|
|
|
|
|
|
48 |
</script>
|
49 |
<div id="grid-<?php echo $i ?>" class="ri-grid ri-grid-size-2 ri-shadow" style="display:none;">
|
50 |
<ul>
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
?>
|
55 |
<li>
|
56 |
<a title="<?php echo $entry['caption']['text'] ?>" class="swipebox_grid"
|
57 |
-
|
58 |
-
<img alt="<?php echo $entry['caption']['text'] ?>"
|
|
|
59 |
</a>
|
60 |
</li>
|
61 |
-
|
62 |
</ul>
|
63 |
</div>
|
3 |
* Grid shortcode template
|
4 |
*/
|
5 |
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit;
|
8 |
}
|
9 |
|
10 |
?>
|
11 |
<script type="text/javascript">
|
12 |
+
jQuery(function () {
|
13 |
+
jQuery('#grid-<?php echo $i; ?>').gridrotator({
|
14 |
+
rows: <?php echo $rows ?>,
|
15 |
+
columns: <?php echo $cols ?>,
|
16 |
+
animType: 'fadeInOut',
|
17 |
+
onhover: false,
|
18 |
+
interval: 7000,
|
19 |
+
preventClick: false,
|
20 |
+
w1400: {
|
21 |
+
rows: <?php echo $rows ?>,
|
22 |
+
columns: <?php echo $cols ?>
|
23 |
+
},
|
24 |
+
w1024: {
|
25 |
+
rows: <?php echo $rows ?>,
|
26 |
+
columns: <?php echo $cols ?>
|
27 |
+
},
|
28 |
+
w768: {
|
29 |
+
rows: <?php echo $rows ?>,
|
30 |
+
columns: <?php echo $cols ?>
|
31 |
+
},
|
32 |
+
w480: {
|
33 |
+
rows: <?php echo $rows ?>,
|
34 |
+
columns: <?php echo $cols ?>
|
35 |
+
},
|
36 |
+
w320: {
|
37 |
+
rows: <?php echo $rows ?>,
|
38 |
+
columns: <?php echo $cols ?>
|
39 |
+
},
|
40 |
+
w240: {
|
41 |
+
rows: <?php echo $rows ?>,
|
42 |
+
columns: <?php echo $cols ?>
|
43 |
+
}
|
|
|
|
|
|
|
44 |
});
|
45 |
+
|
46 |
+
jQuery('#grid-<?php echo $i; ?>').fadeIn('1000');
|
47 |
+
});
|
48 |
</script>
|
49 |
<div id="grid-<?php echo $i ?>" class="ri-grid ri-grid-size-2 ri-shadow" style="display:none;">
|
50 |
<ul>
|
51 |
+
<?php foreach ( $result as $entry ) :
|
52 |
+
$link = $entry['images']['standard_resolution']['url'];
|
53 |
+
?>
|
|
|
54 |
<li>
|
55 |
<a title="<?php echo $entry['caption']['text'] ?>" class="swipebox_grid"
|
56 |
+
href="<?php echo $link ?>">
|
57 |
+
<img alt="<?php echo $entry['caption']['text'] ?>"
|
58 |
+
src="<?php echo $entry['images']['standard_resolution']['url'] ?>">
|
59 |
</a>
|
60 |
</li>
|
61 |
+
<?php endforeach; ?>
|
62 |
</ul>
|
63 |
</div>
|