Feed Them Social – Facebook, Instagram, Twitter, YouTube, Pinterest - Version 2.9.6

Version Description

Download this release

Release Info

Developer slickremix
Plugin Icon 128x128 Feed Them Social – Facebook, Instagram, Twitter, YouTube, Pinterest
Version 2.9.6
Comparing to
See all releases

Code changes from version 2.9.5 to 2.9.6

feed-them.php CHANGED
@@ -7,18 +7,18 @@
7
  * Plugin Name: Feed Them Social - for Twitter feed, Youtube, and more
8
  * Plugin URI: https://feedthemsocial.com/
9
  * Description: Display a Custom Facebook feed, Instagram feed, Twitter feed and YouTube feed on pages, posts or widgets.
10
- * Version: 2.9.5
11
  * Author: SlickRemix
12
  * Author URI: https://www.slickremix.com/
13
  * Text Domain: feed-them-social
14
  * Domain Path: /languages
15
  * Requires at least: WordPress 4.0.0
16
- * Tested up to: WordPress 5.7.0
17
- * Stable tag: 2.9.5
18
  * License: GPLv2 or later
19
  * License URI: https://www.gnu.org/licenses/gpl-3.0.html
20
  *
21
- * @version 2.9.5
22
  * @package FeedThemSocial/Core
23
  * @copyright Copyright (c) 2012-2021 SlickRemix
24
  *
@@ -31,7 +31,7 @@
31
  *
32
  * Makes sure any js or css changes are reloaded properly. Added to enqued css and js files throughout!
33
  */
34
- define( 'FTS_CURRENT_VERSION', '2.9.5' );
35
 
36
  define( 'FEED_THEM_SOCIAL_NOTICE_STATUS', get_option( 'rating_fts_slick_notice', false ) );
37
 
7
  * Plugin Name: Feed Them Social - for Twitter feed, Youtube, and more
8
  * Plugin URI: https://feedthemsocial.com/
9
  * Description: Display a Custom Facebook feed, Instagram feed, Twitter feed and YouTube feed on pages, posts or widgets.
10
+ * Version: 2.9.6
11
  * Author: SlickRemix
12
  * Author URI: https://www.slickremix.com/
13
  * Text Domain: feed-them-social
14
  * Domain Path: /languages
15
  * Requires at least: WordPress 4.0.0
16
+ * Tested up to: WordPress 5.7.1
17
+ * Stable tag: 2.9.6
18
  * License: GPLv2 or later
19
  * License URI: https://www.gnu.org/licenses/gpl-3.0.html
20
  *
21
+ * @version 2.9.6
22
  * @package FeedThemSocial/Core
23
  * @copyright Copyright (c) 2012-2021 SlickRemix
24
  *
31
  *
32
  * Makes sure any js or css changes are reloaded properly. Added to enqued css and js files throughout!
33
  */
34
+ define( 'FTS_CURRENT_VERSION', '2.9.6' );
35
 
36
  define( 'FEED_THEM_SOCIAL_NOTICE_STATUS', get_option( 'rating_fts_slick_notice', false ) );
37
 
feeds/facebook/class-fts-facebook-feed-post-types.php CHANGED
@@ -9,1175 +9,1195 @@
9
  class FTS_Facebook_Feed_Post_Types extends FTS_Facebook_Feed {
10
 
11
 
12
- /**
13
- * Feed Location Option
14
- *
15
- * Display Location flag and text
16
- *
17
- * @param string $fb_places_id The ID.
18
- * @param string $fb_name The facebook page name.
19
- * @param string $fb_places_name The location name.
20
- * @since 1.9.6
21
- */
22
- public function feed_location_option( $fb_places_id, $fb_name, $fb_places_name ) {
23
- echo '<div class="fts-fb-location-wrap">';
24
- echo '<div class="fts-fb-location-img"></div>';
25
- echo '<a href="' . esc_url( 'https://www.facebook.com/' . $fb_places_id . '/' ) . '" class="fts-fb-location-link" target="_blank" rel="noreferrer">' . esc_attr( $fb_name ) . '</a>';
26
- echo '<div class="fts-fb-location-name">' . esc_html( $fb_places_name ) . '</div>';
27
- echo '</div>';
28
- }
29
- /**
30
- * Feed Post Types
31
- *
32
- * Display Facebook Feed.
33
- *
34
- * @param string $set_zero A way to skip posts.
35
- * @param string $fb_type The type of Facebook Feed.
36
- * @param string $post_data All post info.
37
- * @param string $fb_shortcode All shortcode options picked.
38
- * @param string $response_post_array All post info.
39
- * @param string $single_event_array_response All post info.
40
- * @since 1.9.6
41
- */
42
- public function feed_post_types( $set_zero, $fb_type, $post_data, $fb_shortcode, $response_post_array, $single_event_array_response = null ) {
43
-
44
- // echo '<pre>';
45
- // print_r($lcs_array);
46
- // echo '</pre>';
47
- // echo 'ASDF';
48
- // Reviews Plugin.
49
- if ( is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) ) {
50
- $fts_facebook_reviews = new FTS_Facebook_Reviews();
51
- }
52
-
53
- $fts_dynamic_vid_name_string = sanitize_key( $this->fts_rand_string( 10 ) . '_' . $fb_shortcode['type'] );
54
-
55
- if ( $set_zero === $fb_shortcode['posts'] ) {
56
- return;
57
- }
58
- // Create Facebook Variables.
59
- $fb_final_story = '';
60
- $first_dir = '';
61
- $fb_picture = isset( $post_data->picture ) ? $post_data->picture : '';
62
- $fb_link = isset( $post_data->link ) ? $post_data->link : '';
63
- $fb_name = isset( $post_data->name ) ? $post_data->name : '';
64
- $fb_caption = isset( $post_data->caption ) ? $post_data->caption : '';
65
- $fb_description = isset( $post_data->description ) ? $post_data->description : '';
66
- $fb_link_event_name = isset( $post_data->to->data[0]->name ) ? $post_data->to->data[0]->name : '';
67
- $fb_story = isset( $post_data->story ) ? $post_data->story : '';
68
- $fb_icon = isset( $post_data->icon ) ? $post_data->icon : '';
69
- $fb_by = isset( $post_data->properties->text ) ? $post_data->properties->text : '';
70
- $fb_bylink = isset( $post_data->properties->href ) ? $post_data->properties->href : '';
71
- $fb_post_share_count = isset( $post_data->shares->count ) ? $post_data->shares->count : '';
72
- $fb_post_like_count_array = isset( $post_data->likes->data ) ? $post_data->likes->data : '';
73
- $fb_post_comments_count_array = isset( $post_data->comments->data ) ? $post_data->comments->data : '';
74
- $fb_post_object_id = isset( $post_data->object_id ) ? $post_data->object_id : '';
75
- $fb_album_photo_count = isset( $post_data->count ) ? $post_data->count : '';
76
- $fb_album_cover = isset( $post_data->photos->data[0]->images[0]->source ) ? $post_data->photos->data[0]->images[0]->source : '';
77
- $fb_album_picture = isset( $post_data->source ) ? $post_data->source : '';
78
- $fb_places_name = isset( $post_data->place->name ) ? $post_data->place->name : '';
79
- $fb_places_id = isset( $post_data->place->id ) ? $post_data->place->id : '';
80
-
81
- $fb_attachments_title = isset( $post_data->attachments->data[0]->title ) ? $post_data->attachments->data[0]->title : '';
82
- $fb_attachments = isset( $post_data->attachments ) ? $post_data->attachments : '';
83
- $fb_picture_job = isset( $post_data->attachments->data[0]->media->image->src ) ? $post_data->attachments->data[0]->media->image->src : '';
84
- // youtube and vimeo embed url.
85
- $fb_video_embed = isset( $post_data->source ) ? $post_data->source : '';
86
-
87
- $fb_post_from_id = isset( $post_data->from->id ) ? $post_data->from->id : '';
88
- $from_id_picture = $fb_post_from_id !== $fb_shortcode['id'] ? $fb_shortcode['id'] : $fb_post_from_id;
89
-
90
- // if (isset($post_data->format[1]->picture)) {.
91
- // $video_photo = $post_data->format[1]->picture;.
92
- // } elseif (isset($post_data->format[0]->picture)) {.
93
- // $video_photo = $post_data->format[0]->picture;.
94
- // } else {.
95
- // $video_photo = $post_data->picture;.
96
- // }.
97
- if ( isset( $post_data->format[3]->picture ) ) {
98
- $video_photo = $post_data->format[3]->picture;
99
- } elseif ( isset( $post_data->format[2]->picture ) ) {
100
- $video_photo = $post_data->format[2]->picture;
101
- } elseif ( isset( $post_data->format[1]->picture ) ) {
102
- $video_photo = $post_data->format[1]->picture;
103
- } elseif ( isset( $post_data->format[0]->picture ) ) {
104
- $video_photo = $post_data->format[0]->picture;
105
- } else {
106
- $video_photo = '';
107
- }
108
-
109
- if ( ! empty( $post_data->format[3]->height ) && '0' !== $post_data->format[3]->height ) {
110
- $embed_html = $post_data->format[3]->embed_html;
111
-
112
- $embed_width = $post_data->format[3]->width;
113
- $embed_height = $post_data->format[3]->height;
114
- } elseif ( ! empty( $post_data->format[2]->height ) && '0' !== $post_data->format[2]->height ) {
115
- $embed_html = $post_data->format[2]->embed_html;
116
- $embed_width = $post_data->format[2]->width;
117
- $embed_height = $post_data->format[2]->height;
118
- } elseif ( ! empty( $post_data->format[1]->height ) && '0' !== $post_data->format[1]->height ) {
119
- $embed_html = $post_data->format[1]->embed_html;
120
- $embed_width = $post_data->format[1]->width;
121
- $embed_height = $post_data->format[1]->height;
122
- } elseif ( ! empty( $post_data->format[0]->height ) && '0' !== $post_data->format[0]->height ) {
123
- $embed_html = $post_data->format[0]->embed_html;
124
- $embed_width = $post_data->format[0]->width;
125
- $embed_height = $post_data->format[0]->height;
126
- } else {
127
- $embed_html = 'none';
128
- $embed_width = '';
129
- $embed_height = '';
130
- }
131
-
132
- // This will take our embed iframe from the array and then strip out the src url for the iframe so we can.
133
- // add this to our maginific popup.
134
- if ( 'none' !== $embed_html ) {
135
- preg_match( '/src="([^"]+)"/', $embed_html, $match );
136
-
137
- $embed_html = $match[1] . '&autoplay=true';
138
- // we do this check so we can add a data-height class name for our popup to know that we need to add the height to the iframe.
139
- // otherwise we let the magnific pop up scaler class do the work.
140
- if ( $embed_height > $embed_width ) {
141
- $data_height = 'fts-greater-than-width-height';
142
- } elseif ( $embed_height === $embed_width ) {
143
- $data_height = 'fts-equal-width-height';
144
- } else {
145
- $data_height = '';
146
- }
147
- // fts-view-fb-videos-btn.
148
- $fts_view_fb_videos_btn = 'fts-view-fb-videos-btn';
149
-
150
- } else {
151
- $embed_html = $video_photo;
152
- $fts_view_fb_videos_btn = '';
153
- $data_height = '';
154
- }
155
-
156
- $fb_video = isset( $post_data->embed_html ) ? $post_data->embed_html : '';
157
- $fb_video_picture = isset( $post_data->format[2]->picture ) ? $post_data->format[2]->picture : '';
158
-
159
- if ( $fb_album_cover ) {
160
- // $photo_data = json_decode( $response_post_array[ $fb_album_cover . '_photo' ] );
161
- }
162
- if ( isset( $post_data->id ) ) {
163
- $fb_post_id = $post_data->id;
164
- $fb_post_full_id = explode( '_', $fb_post_id );
165
- if ( isset( $fb_post_full_id[0] ) ) {
166
- $fb_post_user_id = $fb_post_full_id[0];
167
- }
168
- if ( isset( $fb_post_full_id[1] ) ) {
169
- $fb_post_single_id = $fb_post_full_id[1];
170
- } else {
171
- $fb_post_single_id = '';
172
- }
173
- } else {
174
- $fb_post_id = '';
175
- $fb_post_user_id = '';
176
- }
177
-
178
- $fb_joblink = isset( $post_data->id, $post_data->from->id ) ? 'https://www.facebook.com/' . $post_data->from->id . '/posts/' . $fb_post_single_id . '' : '';
179
-
180
- if ( 'albums' === $fb_shortcode['type'] && ! $fb_album_cover ) {
181
- unset( $post_data );
182
- }
183
- // Create Post Data Key.
184
- if ( isset( $post_data->object_id ) ) {
185
- $post_data_key = $post_data->object_id;
186
- } else {
187
- $post_data_key = isset( $post_data->id ) ? $post_data->id : '';
188
- }
189
- // Count Likes/Shares/.
190
- $lcs_array = $this->get_likes_shares_comments( $response_post_array, $post_data_key, $fb_post_share_count );
191
-
192
- // echo '<pre>';
193
- // print_r($fb_post_share_count);
194
- // echo '</pre>';
195
-
196
- // $fb_location = isset( $post_data->location ) ? $post_data->location : '';
197
- $fb_embed_vid = isset( $post_data->embed_html ) ? $post_data->embed_html : '';
198
- $fb_from_name = isset( $post_data->from->name ) ? $post_data->from->name : '';
199
- $fb_from_name = preg_quote( $fb_from_name, '/' );
200
-
201
- $fb_story = isset( $post_data->story ) ? $post_data->story : '';
202
- $fts_custom_date = get_option( 'fts-custom-date' ) ? get_option( 'fts-custom-date' ) : '';
203
- $fts_custom_time = get_option( 'fts-custom-time' ) ? get_option( 'fts-custom-time' ) : '';
204
- $custom_date_check = get_option( 'fts-date-and-time-format' ) ? get_option( 'fts-date-and-time-format' ) : '';
205
-
206
- $fb_picture_gallery1 = isset( $post_data->attachments->data[0]->subattachments->data[1]->media->image->src ) ? $post_data->attachments->data[0]->subattachments->data[1]->media->image->src : '';
207
- $fb_picture_gallery2 = isset( $post_data->attachments->data[0]->subattachments->data[2]->media->image->src ) ? $post_data->attachments->data[0]->subattachments->data[2]->media->image->src : '';
208
- $fb_picture_gallery3 = isset( $post_data->attachments->data[0]->subattachments->data[3]->media->image->src ) ? $post_data->attachments->data[0]->subattachments->data[3]->media->image->src : '';
209
-
210
- // we get the width of the first attachment so we can set the max width for the frame around the main image and thumbs.. this makes it so our percent width on thumbnails are nice and aligned.
211
- $fb_picture_gallery0_width = isset( $post_data->attachments->data[0]->subattachments->data[0]->media->image->src ) ? $post_data->attachments->data[0]->subattachments->data[0]->media->image->width : '';
212
-
213
- // June 22, 2017 - Going to leave the attachments description idea for a future update, lots more work to get the likes and comments for attachments and have that info be in the popup.
214
- // $fb_pictureGalleryDescription0 = isset($post_data->attachments->data[0]->subattachments->data[1]->description) ? $post_data->attachments->data[0]->subattachments->data[1]->media->image->src : '';.
215
- // $fb_pictureGalleryDescription1 = isset($post_data->attachments->data[0]->subattachments->data[2]->description)? $post_data->attachments->data[0]->subattachments->data[2]->media->image->src : '';.
216
- // $fb_pictureGalleryDescription2 = isset($post_data->attachments->data[0]->subattachments->data[3]->description) ? $post_data->attachments->data[0]->subattachments->data[3]->media->image->src : '';.
217
- // KZeni Edit: https://github.com/KZeni
218
- // February 25, 2019 - Uncommented Description variables so they can be used when making it so the pictures meet accessibility standards.
219
- $picture_from_fb = __( 'Picture from Facebook', 'feed-them-social' );
220
- $fb_pictureGalleryDescription0 = isset( $post_data->attachments->data[0]->subattachments->data[1]->description ) ? $post_data->attachments->data[0]->subattachments->data[1]->description : $picture_from_fb;
221
- $fb_pictureGalleryDescription1 = isset( $post_data->attachments->data[0]->subattachments->data[2]->description ) ? $post_data->attachments->data[0]->subattachments->data[2]->description : $picture_from_fb;
222
- $fb_pictureGalleryDescription2 = isset( $post_data->attachments->data[0]->subattachments->data[3]->description ) ? $post_data->attachments->data[0]->subattachments->data[3]->description : $picture_from_fb;
223
-
224
- $fb_picture_gallery_link1 = isset( $post_data->attachments->data[0]->subattachments->data[1]->target->url ) ? $post_data->attachments->data[0]->subattachments->data[1]->target->url : '';
225
- $fb_picture_gallery_link2 = isset( $post_data->attachments->data[0]->subattachments->data[2]->target->url ) ? $post_data->attachments->data[0]->subattachments->data[2]->target->url : '';
226
- $fb_picture_gallery_link3 = isset( $post_data->attachments->data[0]->subattachments->data[3]->target->url ) ? $post_data->attachments->data[0]->subattachments->data[3]->target->url : '';
227
-
228
- if ( isset( $fb_shortcode['scrollhorz_or_carousel'], $fb_shortcode['slider_spacing'] ) && ! empty( $fb_shortcode['slider_spacing'] ) && 'carousel' === $fb_shortcode['scrollhorz_or_carousel'] ) {
229
-
230
- $fb_shortcode['space_between_photos'] = '0 ' . $fb_shortcode['slider_spacing'];
231
-
232
- }
233
-
234
- if ( empty( $fts_custom_date ) && empty( $fts_custom_time ) && 'fts-custom-date' !== $custom_date_check ) {
235
- $custom_date_format = $custom_date_check;
236
- } elseif ( ! empty( $fts_custom_date ) && 'fts-custom-date' === $custom_date_check || ! empty( $fts_custom_time ) && 'fts-custom-date' === $custom_date_check ) {
237
- $custom_date_format = $fts_custom_date . ' ' . $fts_custom_time;
238
- } else {
239
- $custom_date_format = 'F jS, Y \a\t g:ia';
240
- }
241
-
242
- $album_created_time = isset( $post_data->photos->data[0]->created_time ) ? $post_data->photos->data[0]->created_time : '';
243
- $other_created_time = isset( $post_data->created_time ) ? $post_data->created_time : '';
244
- $created_time = '' !== $album_created_time ? $album_created_time : $other_created_time;
245
- $custom_time_format = strtotime( $created_time );
246
-
247
- if ( ! empty( $fb_story ) ) {
248
- $fb_final_story = preg_replace( '/\b' . $fb_from_name . 's*?\b(?=([^"]*"[^"]*")*[^"]*$)/i', '', $fb_story, 1 );
249
- }
250
-
251
- $fts_hide_photos_type = get_option( 'fb_hide_images_in_posts' ) ? get_option( 'fb_hide_images_in_posts' ) : 'no';
252
-
253
- switch ( $fb_type ) {
254
- case 'video':
255
- echo '<div class="fts-jal-single-fb-post fts-fb-video-post-wrap" ';
256
- if ( isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] ) {
257
- echo 'style="width:' . esc_attr( $fb_shortcode['colmn_width'] ) . '!important; margin:' . esc_attr( $fb_shortcode['space_between_posts'] ) . '!important"';
258
- }
259
- echo '>';
260
-
261
- break;
262
- case 'app':
263
- case 'cover':
264
- case 'profile':
265
- case 'mobile':
266
- case 'wall':
267
- case 'normal':
268
- case 'photo':
269
- echo "<div class='fts-fb-photo-post-wrap fts-jal-single-fb-post' ";
270
- if ( 'album_photos' === $fb_shortcode['type'] || 'albums' === $fb_shortcode['type'] ) {
271
-
272
- if ( isset( $fb_shortcode['scrollhorz_or_carousel'] ) && 'scrollhorz' === $fb_shortcode['scrollhorz_or_carousel'] ) {
273
- echo 'style="max-width:' . esc_attr( $fb_shortcode['image_width'] ) . ';height:100%; margin:' . esc_attr( $fb_shortcode['space_between_photos'] ) . '!important"';
274
- } else {
275
- echo 'style="width:' . esc_attr( $fb_shortcode['image_width'] ) . ' !important; height:' . esc_attr( $fb_shortcode['image_height'] ) . '!important; margin:' . esc_attr( $fb_shortcode['space_between_photos'] ) . '!important"';
276
- }
277
- }
278
- if ( isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] ) {
279
- echo 'style="width:' . esc_attr( $fb_shortcode['colmn_width'] ) . '!important; margin:' . esc_attr( $fb_shortcode['space_between_posts'] ) . '!important"';
280
- }
281
- echo '>';
282
-
283
- break;
284
- case 'album':
285
- default:
286
- echo '<div class="fts-jal-single-fb-post"';
287
- if ( isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] ) {
288
- echo 'style="width:' . esc_attr( $fb_shortcode['colmn_width'] ) . '!important; margin:' . esc_attr( $fb_shortcode['space_between_posts'] ) . '!important"';
289
- }
290
- echo '>';
291
- break;
292
- }
293
- // output Single Post Wrap.
294
- // Don't echo if Events Feed.
295
- if ( 'events' !== $fb_shortcode['type'] ) {
296
-
297
- // Reviews.
298
- $itemscope_reviews = 'reviews' === $fb_shortcode['type'] && isset( $post_data->rating ) ? 'itemscope itemtype="http://schema.org/Review"' : '';
299
-
300
- // Right Wrap.
301
- // $review_rating CANNOT be esc at this time.
302
- echo '<div ' . esc_attr( $itemscope_reviews ) . ' class="fts-jal-fb-right-wrap">';
303
- if ( 'reviews' === $fb_shortcode['type'] && isset( $post_data->rating ) ) {
304
- echo '<meta itemprop="itemReviewed" itemscope itemtype="http://schema.org/CreativeWork"><div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" style="display: none;"><meta itemprop="worstRating" content = "1"><meta itemprop="ratingValue" content = "' . esc_attr( $post_data->rating ) . '"><meta itemprop="bestRating" content = "5"></div>';
305
- }
306
- // Top Wrap (Excluding : albums, album_photos, and hiding).
307
- $hide_date_likes_comments = 'album_photos' === $fb_shortcode['type'] && 'yes' === $fb_shortcode['hide_date_likes_comments'] || 'albums' === $fb_shortcode['type'] && 'yes' === $fb_shortcode['hide_date_likes_comments'] ? 'hide-date-likes-comments-etc' : '';
308
-
309
- $show_media = isset( $fb_shortcode['show_media'] ) ? $fb_shortcode['show_media'] : 'bottom';
310
-
311
- if ( 'top' !== $show_media ) {
312
- echo '<div class="fts-jal-fb-top-wrap ' . esc_attr( $hide_date_likes_comments ) . '">';
313
- }
314
- // if ($fb_shortcode['type'] == 'album_photos' || $fb_shortcode['type'] == 'albums') {.
315
- // } else {.
316
- // User Thumbnail.
317
- $fb_hide_shared_by_etc_text = get_option( 'fb_hide_shared_by_etc_text' );
318
- $fb_hide_shared_by_etc_text = isset( $fb_hide_shared_by_etc_text ) && 'no' === $fb_hide_shared_by_etc_text ? '' : $fb_final_story;
319
-
320
- if ( 'top' !== $show_media ) {
321
-
322
- if ( 'albums' !== $fb_shortcode['type'] ) {
323
- echo '<div class="fts-jal-fb-user-thumb">';
324
-
325
- $avatar_id = plugin_dir_url( __DIR__ ) . 'images/slick-comment-pic.png';
326
- $profile_photo_exists_check = isset( $post_data->fts_profile_pic_url ) && strpos( $post_data->fts_profile_pic_url, 'profilepic' ) !== false ? $post_data->fts_profile_pic_url : $avatar_id;
327
-
328
- echo ( 'reviews' === esc_attr( $fb_shortcode['type'] ) ? '' : '<a href="https://www.facebook.com/' . esc_attr( $from_id_picture ) . '" target="_blank" rel="noreferrer">' ) . '<img border="0" alt="' . ( 'reviews' === esc_attr( $fb_shortcode['type'] ) ? esc_attr( $post_data->reviewer->name ) : esc_attr( $post_data->from->name ) ) . '" src="' . ( 'reviews' === esc_attr( $fb_shortcode['type'] ) ? esc_url( $profile_photo_exists_check ) . '"/>' : 'https://graph.facebook.com/' . esc_attr( $from_id_picture ) ) . ( 'reviews' === esc_attr( $fb_shortcode['type'] ) ? '' : '/picture"/></a>' );
329
-
330
- echo '</div>';
331
-
332
- }
333
-
334
- // UserName.
335
- // $fts_facebook_reviews->reviews_rating_format CANNOT be esc at this time.
336
- $hide_name = 'albums' === $fb_shortcode['type'] ? ' fts-fb-album-hide' : '';
337
-
338
- echo ( 'reviews' === $fb_shortcode['type'] && is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) ? '<span class="fts-jal-fb-user-name fts-review-name" itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">' . esc_attr( $post_data->reviewer->name ) . '</span>' . $fts_facebook_reviews->reviews_rating_format( $fb_shortcode, isset( $post_data->rating ) ? esc_html( $post_data->rating ) : '' ) . '</span>' : '<span class="fts-jal-fb-user-name' . $hide_name . '"><a href="https://www.facebook.com/' . esc_attr( $from_id_picture ) . '" target="_blank" rel="noreferrer">' . esc_html( $post_data->from->name ) . '</a>' . esc_html( $fb_hide_shared_by_etc_text ) . '</span>' );
339
-
340
- // tied to date function.
341
- $feed_type = 'facebook';
342
- $times = $custom_time_format;
343
- $fts_final_date = $this->fts_custom_date( $times, $feed_type );
344
- // PostTime.
345
- // $fts_final_date CANNOT be esc at this time.
346
- if ( 'albums' !== $fb_shortcode['type'] ) {
347
- echo '<span class="fts-jal-fb-post-time">' . $fts_final_date . '</span><div class="fts-clear"></div>';
348
- }
349
- }
350
-
351
- if ( 'reviews' !== $fb_shortcode['type'] ) {
352
- // Comments Count.
353
- $fb_post_id_final = substr( $fb_post_id, strpos( $fb_post_id, '_' ) + 1 );
354
- }
355
-
356
- $fb_title_job_opening = isset( $post_data->attachments->data[0]->title ) && 'job_search_job_opening' === $post_data->attachments->data[0]->type ? $post_data->attachments->data[0]->title : '';
357
-
358
- // filter messages to have urls.
359
- // Output Message.
360
- $fb_message = ( isset( $post_data->message ) ? $post_data->message : ( isset( $post_data->review_text ) ? $post_data->review_text : '' ) . '' );
361
- if ( empty( $fb_message ) ) {
362
-
363
- if ( isset( $post_data->description ) ) {
364
- $fb_message = isset( $post_data->description ) ? $post_data->description : '';
365
- } elseif ( isset( $post_data->attachments->data[0]->description ) ) {
366
- $fb_message = isset( $post_data->attachments->data[0]->description ) ? $post_data->attachments->data[0]->description : '';
367
- }
368
- }
369
-
370
- if ( $fb_message && 'top' !== $show_media ) {
371
-
372
- if ( ! empty( $fb_places_id ) ) {
373
- $this->feed_location_option( $fb_places_id, $fb_name, $fb_places_name );
374
- }
375
-
376
- $itemprop_description_reviews = is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) ? ' itemprop="description"' : '';
377
-
378
- // here we trim the words for the premium version. The $fb_shortcode['words'] string actually comes from the javascript.
379
- if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && array_key_exists( 'words', $fb_shortcode ) && 'top' !== $show_media || is_plugin_active( 'feed-them-social-combined-streams/feed-them-social-combined-streams.php' ) && array_key_exists( 'words', $fb_shortcode ) && ! empty( $fb_shortcode['words'] ) && 'top' !== $show_media || is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && array_key_exists( 'words', $fb_shortcode ) && 'top' !== $show_media ) {
380
- $more = isset( $more ) ? $more : '';
381
-
382
- $trimmed_content = $this->fts_custom_trim_words( $fb_message, $fb_shortcode['words'], $more );
383
-
384
- // Going to consider this for the future if facebook fixes the api to define when are checking in. Add '.$checked_in.' inside the fts-jal-fb-message div.
385
- // $checked_in = '<a target="_blank" class="fts-checked-in-img" href="https://www.facebook.com/'.$post_data->place->id.'"><img src="https://graph.facebook.com/'.$post_data->place->id.'/picture?width=150"/></a><a target="_blank" class="fts-checked-in-text-link" href="https://www.facebook.com/'.$post_data->place->id.'">'.esc_html("Checked in at", "feed-them-social").' '.$post_data->place->name.'</a><br/> '.esc_html("Location", "feed-them-social").': '.$post_data->place->location->city.', '.$post_data->place->location->country.' '.$post_data->place->location->zip.'<br/><a target="_blank" class="fts-fb-get-directions fts-checked-in-get-directions" href="https://www.facebook.com/'.$post_data->place->id.'">'.esc_html("Get Direction", "feed-them-social").'</a>';.
386
- echo '<div class="fts-jal-fb-message"' . esc_attr( $itemprop_description_reviews ) . '>';
387
-
388
- echo esc_html( $fb_title_job_opening );
389
- // $trimmed_content CANNOT be esc at this time.
390
- echo ! empty( $trimmed_content ) ? $trimmed_content : '';
391
- // The Popup.
392
- // echo $fb_shortcode['popup'] == 'yes' ? '<div class="fts-fb-caption"><a href="' . $fb_link . '" class="fts-view-on-facebook-link" target="_blank">' . esc_html__('View on Facebook', 'feed-them-social') . '</a></div> ' : '';.
393
- echo '<div class="fts-clear"></div></div> ';
394
-
395
- } elseif ( 'top' !== $show_media ) {
396
- $fb_final_message = $this->fts_facebook_tag_filter( $fb_message );
397
- echo '<div class="fts-jal-fb-message"' . esc_attr( $itemprop_description_reviews ) . '>';
398
- // $fb_final_message CANNOT be esc at this time.
399
- echo nl2br( $fb_final_message );
400
- // If POPUP.
401
- // echo isset($fb_shortcode['popup']) && $fb_shortcode['popup'] == 'yes' ? '<div class="fts-fb-caption"><a href="' . $fb_link . '" class="fts-view-on-facebook-link" target="_blank">' . esc_html('View on Facebook', 'feed-them-facebook') . '</a></div> ' : '';.
402
- echo '<div class="fts-clear"></div></div>';
403
- }
404
- } elseif ( ! $fb_message && 'album_photos' === $fb_shortcode['type'] || ! $fb_message && 'albums' === $fb_shortcode['type'] ) {
405
-
406
- echo '<div class="fts-jal-fb-description-wrap">';
407
-
408
- $fb_caption ? $this->fts_facebook_post_cap( $fb_caption, $fb_shortcode, $fb_type ) : '';
409
- // Output Photo Caption.
410
- // if ( !is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && 'albums' === $fb_shortcode['type'] ){
411
- // Album Post Description.
412
- if ( 'albums' === $fb_shortcode['type'] ) {
413
- echo '<div class="fts-fb-album-name-and-count ">';
414
- }
415
- $fb_name ? $this->fts_facebook_post_desc( $fb_name, $fb_shortcode, $fb_type, null, $fb_by ) : '';
416
- // echo $fb_type;
417
- // echo 'asdfasdf';
418
- // Albums Photo Count.
419
- echo $fb_album_photo_count ? esc_html( $fb_album_photo_count ) . ' Photos' : '';
420
- if ( 'albums' === $fb_shortcode['type'] ) {
421
- echo '</div>';
422
- }
423
- // }
424
- // Location.
425
- // $fb_location ? $this->fts_facebook_location( $fb_type, $fb_location ) : '';
426
- // Output Photo Description.
427
- $fb_description ? $this->fts_facebook_post_desc( $fb_description, $fb_shortcode, $fb_type, null, $fb_by ) : '';
428
-
429
- // Output Photo Description.
430
- if ( isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ) {
431
- echo '<div class="fts-fb-caption fts-fb-album-view-link">';
432
- // Album Covers.
433
- if ( 'albums' === $fb_shortcode['type'] ) {
434
-
435
- echo '<div class="fts-fb-album-additional-pics">';
436
- // Album Covers. <img src="' . esc_url( $fb_album_additional_pic->images[1]->source ) . '"/>
437
- $isFirst = true;
438
- foreach ( $post_data->photos->data as $key => $fb_album_additional_pic ) {
439
- // $fb_album_additional_pic_check = isset( $fb_album_additional_pic->name ) ? $this->fts_facebook_post_desc( $fb_album_additional_pic->name, $fb_shortcode, $fb_type, null, $fb_by ): '';
440
- // $fb_album_additional_pic ? $fb_album_additional_pic_check : '';
441
- echo '<div class="fts-fb-album-additional-pics-content">';
442
-
443
- $hide_all_but_one_link = ! $isFirst ? 'style="display:none"' : '';
444
-
445
- echo '<a href="' . esc_url( $fb_album_additional_pic->images[0]->source ) . '" class="fts-view-album-photos-large data-fb-album-photo-description" target="_blank" rel="noreferrer" ' . $hide_all_but_one_link . '>' . esc_html__( 'View Album', 'feed-them-social' ) . '</a>';
446
- echo '<div class="fts-fb-album-additional-pics-description-wrap">';
447
- echo '<div class="fts-jal-fb-description-wrap fts-fb-album-description-content fts-jal-fb-description-popup">';
448
-
449
- // tied to date function.
450
- $feed_type = 'facebook';
451
- $album_created_time = isset( $fb_album_additional_pic->created_time ) ? $fb_album_additional_pic->created_time : '';
452
- $times = $album_created_time;
453
- $fts_final_date = $this->fts_custom_date( $times, $feed_type );
454
- echo '<div class="fts-jal-fb-user-thumb">';
455
- echo '<a href="https://www.facebook.com/' . esc_attr( $from_id_picture ) . '" target="_blank" rel="noreferrer"><img border="0" alt="' . esc_attr( $post_data->from->name ) . '" src="' . 'https://graph.facebook.com/' . esc_attr( $from_id_picture ) . '/picture"/></a>';
456
- echo '</div>';
457
-
458
- // UserName.
459
- // $fts_facebook_reviews->reviews_rating_format CANNOT be esc at this time.
460
- echo '<span class="fts-jal-fb-user-name"><a href="https://www.facebook.com/' . esc_attr( $from_id_picture ) . '" target="_blank" rel="noreferrer">' . esc_html( $post_data->from->name ) . '</a>' . esc_html( $fb_hide_shared_by_etc_text ) . '</span>';
461
-
462
- echo '<div class="fts-fb-album-date-wrap">' . $fts_final_date . '</div>';
463
-
464
- echo '<div class="fts-clear"></div>';
465
-
466
- // Album Post Description.
467
- // $fb_name ? $this->fts_facebook_post_desc( $fb_name, $fb_shortcode, $fb_type, null, $fb_by ) : '';
468
- // Albums Photo Count.
469
- $fb_name ? $this->fts_facebook_post_desc( $fb_name, $fb_shortcode, $fb_type, null, $fb_by ) : '';
470
- $view_additional_album_photos = '24' == $key ? '. <a href="' . $fb_link . '" target="_blank" rel="noreferrer">' . esc_html__( 'View more for this Album', 'feed-them-social' ) . '</a>' : '';
471
- echo $fb_album_photo_count ? ' ' . esc_html( $key + 1 ) . ' ' . esc_html__( 'of', 'feed-them-social' ) . ' ' . esc_html( $fb_album_photo_count ) . ' ' . esc_html__( 'Photos', 'feed-them-social' ) . ' ' . $view_additional_album_photos : '';
472
- echo '<br/><br/>';
473
-
474
- $fb_album_additional_pic_name = isset( $fb_album_additional_pic->name ) ? $fb_album_additional_pic->name : '';
475
- $fb_album_additional_pic_name ? $this->fts_facebook_post_desc( $fb_album_additional_pic_name, $fb_shortcode, $fb_type, null, $fb_by ) : '';
476
- echo '</div>';
477
- echo '</div>';
478
- echo '</div>';
479
- $isFirst = false;
480
- }
481
-
482
- echo '</div>';
483
- echo '</div>';
484
- } elseif (
485
-
486
- // Album Photos.
487
- 'album_photos' === $fb_shortcode['type'] && ( isset( $fb_shortcode['video_album'] ) && 'yes' !== $fb_shortcode['video_album'] || ! isset( $fb_shortcode['video_album'] ) ) ) {
488
- echo '<a href="' . esc_url( $fb_album_picture ) . '" class="fts-view-album-photos-large" target="_blank" rel="noreferrer">' . esc_html__( 'View Photo', 'feed-them-social' ) . '</a></div>';
489
-
490
- } elseif (
491
- // Video Albums.
492
- isset( $fb_shortcode['video_album'] ) && 'yes' === $fb_shortcode['video_album'] ) {
493
- if ( 'yes' !== $fb_shortcode['play_btn'] ) {
494
-
495
- echo '<a href="' . esc_url( $embed_html ) . '" data-poster="' . esc_url( $video_photo ) . '" id="fts-view-vid1-' . esc_attr( $fts_dynamic_vid_name_string ) . '" class="fts-jal-fb-vid-html5video ' . esc_attr( $fts_view_fb_videos_btn ) . ' fts-view-fb-videos-large fts-view-fb-videos-btn fb-video-popup-' . esc_attr( $fts_dynamic_vid_name_string ) . '">' . esc_html__( 'View Video', 'feed-them-social' ) . '</a>';
496
-
497
- echo '<div class="fts-fb-embed-iframe-check-used-for-popup fts-fb-embed-yes">';
498
- if ( $embed_height >= $embed_width ) {
499
- echo '<div class=' . esc_url( $data_height ) . ' data-width="' . esc_attr( $embed_width ) . '" data-height="' . esc_attr( $embed_height ) . '"></div>';
500
- }
501
- echo '</div>';
502
- }
503
- echo '</div>';
504
- } else {
505
- // photos.
506
- echo '<a href="' . esc_url( $post_data->source ) . '" class="fts-view-album-photos-large" target="_blank" rel="noreferrer">' . esc_html__( 'View Photo', 'feed-them-social' ) . '</a></div>';
507
- }
508
-
509
- // echo '<div class="fts-fb-caption"><a class="view-on-facebook-albums-link" href="' . $fb_link . '" target="_blank">' . esc_html('View on Facebook', 'feed-them-social') . '</a></div>';.
510
- }
511
-
512
- echo '<div class="fts-clear"></div></div>';
513
- } //END Output Message
514
- // elseif ($fb_message == '' && $fb_shortcode['type'] !== 'album_photos' || $fb_message == '' && $fb_shortcode['type'] !== 'albums') {.
515
- // If POPUP.
516
- // echo $fb_shortcode['popup'] == 'yes' ? '<div class="fts-jal-fb-message"><div class="fts-fb-caption"><a href="' . $fb_link . '" class="fts-view-on-facebook-link" target="_blank">' . esc_html('View on Facebook', 'feed-them-facebook') . '</a></div></div>' : '';.
517
- // }.
518
- if ( 'top' !== $show_media ) {
519
- echo '</div>';
520
- // end .fts-jal-fb-top-wrap <!--end fts-jal-fb-top-wrap -->.
521
- }
522
- }
523
- // Post Type Build.
524
- $fts_show_post = false;
525
- switch ( $fb_type ) {
526
-
527
- // START NOTE POST.
528
- case 'note':
529
- // && !$fb_picture == '' makes it so the attachment unavailable message does not show up.
530
- // if (!$fb_picture && !$fb_name && !$fb_description && !$fb_picture == '') {.
531
- echo '<div class="fts-jal-fb-link-wrap">';
532
- // Output Link Picture.
533
- $fb_picture ? $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, $post_data->full_picture ) : '';
534
-
535
- if ( $fb_name || $fb_caption || $fb_description ) {
536
- echo '<div class="fts-jal-fb-description-wrap">';
537
- // Output Link Name.
538
- $fb_name ? $this->fts_facebook_post_name( $fb_link, $fb_name, $fb_type ) : '';
539
- // Output Link Caption.
540
- if ( 'Attachment Unavailable. This attachment may have been removed or the person who shared it may not have permission to share it with you.' === $fb_caption ) {
541
- echo '<div class="fts-jal-fb-caption" style="width:100% !important">';
542
- esc_html( 'This user\'s permissions are keeping you from seeing this post. Please Click "View on Facebook" to view this post on this group\'s facebook wall.', 'feed-them-social' );
543
- echo '</div>';
544
- } else {
545
- $this->fts_facebook_post_cap( $fb_caption, $fb_shortcode, $fb_type );
546
- }
547
- // If POPUP.
548
- // echo $fb_shortcode['popup'] == 'yes' ? '<div class="fts-fb-caption"><a href="' . $fb_link . '" class="fts-view-on-facebook-link" target="_blank">' . esc_html('View on Facebook', 'feed-them-facebook') . '</a></div> ' : '';.
549
- // Output Link Description.
550
- // echo $fb_description ? $this->fts_facebook_post_desc($fb_description, $fb_shortcode, $fb_type) : '';.
551
- echo '<div class="fts-clear"></div></div>';
552
- }
553
- echo '<div class="fts-clear"></div></div>';
554
- // }.
555
- break;
556
-
557
- // START STATUS POST.
558
- case 'status':
559
- // && !$fb_picture == '' makes it so the attachment unavailable message does not show up.
560
- // if (!$fb_picture && !$fb_name && !$fb_description && !$fb_picture == '') {.
561
- echo '<div class="fts-jal-fb-link-wrap">';
562
- // Output Link Picture.
563
- if ( $fb_picture_job ) {
564
- $this->fts_facebook_post_photo( $fb_joblink, $fb_shortcode, $post_data->from->name, $fb_picture_job );
565
- } else {
566
- $fb_picture ? $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, $post_data->picture ) : '';
567
- }
568
-
569
- if ( $fb_name || $fb_caption || $fb_description ) {
570
- echo '<div class="fts-jal-fb-description-wrap">';
571
- // Output Link Name.
572
- $fb_name ? $this->fts_facebook_post_name( $fb_link, $fb_name, $fb_type ) : '';
573
- // Output Link Caption.
574
- if ( 'Attachment Unavailable. This attachment may have been removed or the person who shared it may not have permission to share it with you.' === $fb_caption ) {
575
- echo '<div class="fts-jal-fb-caption" style="width:100% !important">';
576
- echo esc_html( 'This user\'s permissions are keeping you from seeing this post. Please Click "View on Facebook" to view this post on this group\'s facebook wall.', 'feed-them-social' );
577
- echo '</div>';
578
- } else {
579
- $this->fts_facebook_post_cap( $fb_caption, $fb_shortcode, $fb_type );
580
- }
581
- // Output Link Description.
582
- $fb_description ? $this->fts_facebook_post_desc( $fb_description, $fb_shortcode, $fb_type ) : '';
583
- echo '<div class="fts-clear"></div></div>';
584
- }
585
- echo '<div class="fts-clear"></div></div>';
586
- // }
587
- break;
588
- // Start Multiple Events.
589
- case 'events':
590
- $single_event_id = $post_data->id;
591
- $single_event_info = json_decode( $single_event_array_response[ 'event_single_' . $single_event_id . '_info' ] );
592
- $single_event_location = json_decode( $single_event_array_response[ 'event_single_' . $single_event_id . '_location' ] );
593
- $single_event_cover_photo = json_decode( $single_event_array_response[ 'event_single_' . $single_event_id . '_cover_photo' ] );
594
- $single_event_ticket_info = json_decode( $single_event_array_response[ 'event_single_' . $single_event_id . '_ticket_info' ] );
595
- // echo'<pre>';.
596
- // print_r($single_event_info);.
597
- // echo'</pre>';.
598
- // Event Cover Photo.
599
- $event_cover_photo = isset( $single_event_cover_photo->cover->source ) ? $single_event_cover_photo->cover->source : '';
600
- $event_description = isset( $single_event_info->description ) ? $single_event_info->description : '';
601
- echo '<div class="fts-jal-fb-right-wrap fts-events-list-wrap">';
602
- // Link Picture.
603
- $fb_event_name = isset( $single_event_info->name ) ? $single_event_info->name : '';
604
- $fb_event_location = isset( $single_event_location->place->name ) ? $single_event_location->place->name : '';
605
- $fb_event_city = isset( $single_event_location->place->location->city ) ? $single_event_location->place->location->city . ', ' : '';
606
- $fb_event_state = isset( $single_event_location->place->location->state ) ? $single_event_location->place->location->state : '';
607
- $fb_event_street = isset( $single_event_location->place->location->street ) ? $single_event_location->place->location->street : '';
608
- $fb_event_zip = isset( $single_event_location->place->location->zip ) ? ' ' . $single_event_location->place->location->zip : '';
609
- $fb_event_latitude = isset( $single_event_location->place->location->latitude ) ? $single_event_location->place->location->latitude : '';
610
- $fb_event_longitude = isset( $single_event_location->place->location->longitude ) ? $single_event_location->place->location->longitude : '';
611
- $fb_event_ticket_info = isset( $single_event_ticket_info->ticket_uri ) ? $single_event_ticket_info->ticket_uri : '';
612
- date_default_timezone_set( get_option( 'fts-timezone' ) );
613
-
614
- // custom one day ago check.
615
- if ( 'one-day-ago' === $custom_date_check ) {
616
- $fb_event_start_time = date_i18n( 'l, F jS, Y \a\t g:ia', strtotime( $single_event_info->start_time ) );
617
- } else {
618
- $fb_event_start_time = date_i18n( $custom_date_format, strtotime( $single_event_info->start_time ) );
619
- }
620
-
621
- // Output Photo Description.
622
- if ( ! empty( $event_cover_photo ) ) {
623
- echo isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] && is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) ? '<a href="' . esc_url( $event_cover_photo ) . '" class="fts-jal-fb-picture fts-fb-large-photo" target="_blank" rel="noreferrer"><img class="fts-fb-event-photo" src="' . esc_url( $event_cover_photo ) . '"></a>' : '<a href="https://www.facebook.com/events/' . esc_attr( $single_event_id ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-picture fts-fb-large-photo"><img class="fts-fb-event-photo" src="' . esc_url( $event_cover_photo ) . '" /></a>';
624
- }
625
- echo '<div class="fts-jal-fb-top-wrap">';
626
- echo '<div class="fts-jal-fb-message">';
627
- // Link Name.
628
- echo '<div class="fts-event-title-wrap">';
629
- $fb_event_name ? $this->fts_facebook_post_name( 'https://www.facebook.com/events/' . esc_attr( $single_event_id ) . '', esc_attr( $fb_event_name ), esc_attr( $fb_type ) ) : '';
630
- echo '</div>';
631
- // Link Caption.
632
- if ( $fb_event_start_time ) {
633
- echo '<div class="fts-fb-event-time">' . $fb_event_start_time . '</div>';
634
- }
635
- // Link Description.
636
- if ( ! empty( $fb_event_location ) ) {
637
- echo '<div class="fts-fb-location"><span class="fts-fb-location-title">' . esc_html( $fb_event_location ) . '</span>';
638
- // Street Adress.
639
- echo esc_html( $fb_event_street );
640
- // City & State.
641
- echo $fb_event_city || $fb_event_state ? '<br/>' . esc_html( $fb_event_city . $fb_event_state . $fb_event_zip ) : '';
642
- echo '</div>';
643
- }
644
- // Get Directions.
645
- if ( ! empty( $fb_event_latitude ) && ! empty( $fb_event_longitude ) ) {
646
- echo '<a target="_blank" class="fts-fb-get-directions" href="' . esc_html( 'https://www.google.com/maps/dir/Current+Location/' . $fb_event_latitude . ',' . $fb_event_longitude . '' ) . '"
 
 
 
 
 
647
  >' . esc_html( 'Get Directions', 'feed-them-social' ) . '</a>';
648
- }
649
- if ( ! empty( $fb_event_ticket_info ) && ! empty( $fb_event_ticket_info ) ) {
650
- echo '<a target="_blank" rel="noreferrer" class="fts-fb-ticket-info" href="' . esc_url( $single_event_ticket_info->ticket_uri ) . '">' . esc_html( 'Ticket Info', 'feed-them-social' ) . '</a>';
651
- }
652
- // Output Message.
653
- if ( ! empty( $fb_shortcode['words'] ) && $event_description && is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) ) {
654
- // here we trim the words for the premium version. The $fb_shortcode['words'] string actually comes from the javascript.
655
- $this->fts_facebook_post_desc( $event_description, $fb_shortcode, $fb_type, null, $fb_by, $fb_shortcode['type'] );
656
- } else {
657
- // if the premium plugin is not active we will just show the regular full description.
658
- $this->fts_facebook_post_desc( $event_description, $fb_type, null, $fb_by, $fb_shortcode['type'] );
659
- }
660
- // Our POPUP.
661
- // echo $fb_shortcode['popup'] == 'yes' ? '<div class="fts-fb-caption"><a href="https://www.facebook.com/events/' . $single_event_id . '" class="fts-view-on-facebook-link" target="_blank">' . esc_html('View Event on Facebook', 'feed-them-facebook') . '</a></div> ' : '';.
662
- echo '<div class="fts-clear"></div></div></div>';
663
- break;
664
-
665
- // START LINK POST.
666
- case 'link':
667
- echo '<div class="fts-jal-fb-link-wrap">';
668
- // start url check.
669
- if ( ! empty( $fb_link ) ) {
670
- $url = $fb_link;
671
- $url_parts = parse_url( $url );
672
- $host = $url_parts['host'];
673
- }
674
-
675
- if ( isset( $host ) && 'www.facebook.com' === $host ) {
676
- $spliturl = $url_parts['path'];
677
- $path_components = explode( '/', $spliturl );
678
- $first_dir = $path_components[1];
679
- }
680
- // end url check.
681
- // Output Link Picture.
682
- // echo isset($fb_shortcode['popup']) && $fb_shortcode['popup'] == 'yes' ? '<div class="fts-fb-caption"><a href="' . $fb_link . '" class="fts-view-on-facebook-link" target="_blank">' . esc_html('View on Facebook', 'feed-them-social') . '</a></div> ' : '';.
683
- if ( isset( $host ) && 'www.facebook.com' === $host && 'events' === $first_dir ) {
684
- $fb_picture ? $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, $post_data->picture ) : '';
685
- } elseif ( strpos( $fb_link, 'soundcloud' ) > 0 ) {
686
- // Get the SoundCloud URL.
687
- $url = $fb_link;
688
- // Get the JSON data of song details with embed code from SoundCloud oEmbed.
689
- $get_values = file_get_contents( 'http://soundcloud.com/oembed?format=js&url=' . $url . '&auto_play=true&iframe=true' );
690
- // Clean the Json to decode.
691
- $decode_iframe = substr( $get_values, 1, -2 );
692
- // json decode to convert it as an array.
693
- $json_obj = json_decode( $decode_iframe );
694
- // Change the height of the embed player if you want else uncomment below line.
695
- // echo str_replace('height="400"', 'height="140"', $json_obj->html);.
696
- $fts_dynamic_vid_name_string = sanitize_key( $this->fts_rand_string( 10 ) . '_' . $fb_shortcode['type'] );
697
- $fts_dynamic_vid_name = 'feed_dynamic_video_class' . $fts_dynamic_vid_name_string;
698
- echo '<div class="fts-jal-fb-vid-picture ' . esc_attr( $fts_dynamic_vid_name ) . '">';
699
- if ( ! empty( $post_data->full_picture ) ) {
700
- $fb_picture ? $this->fts_facebook_post_photo( 'javascript:;', $fb_shortcode, $post_data->from->name, $post_data->full_picture ) : '';
701
- } elseif ( ! empty( $post_data->picture ) ) {
702
- $fb_picture ? $this->fts_facebook_post_photo( 'javascript:;', $fb_shortcode, $post_data->from->name, $post_data->picture ) : '';
703
- }
704
- echo '<div class="fts-jal-fb-vid-play-btn"></div>';
705
- echo '</div>';
706
- echo '<script>';
707
- echo 'jQuery(document).ready(function() {';
708
- echo 'jQuery(".' . esc_js( $fts_dynamic_vid_name ) . '").click(function() {';
709
- echo 'jQuery(this).addClass("fts-vid-div");';
710
- echo 'jQuery(this).removeClass("fts-jal-fb-vid-picture");';
711
- echo ' jQuery(this).prepend(\'<div class="fts-fluid-videoWrapper">' . $json_obj->html . '</div>\');';
712
- if ( isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] ) {
713
- echo 'jQuery(".fts-slicker-facebook-posts").masonry( "reloadItems");';
714
- echo 'jQuery(".fts-slicker-facebook-posts").masonry( "layout" );';
715
- }
716
- echo '});';
717
- echo '});';
718
- echo '</script>';
719
- } elseif ( ! empty( $post_data->full_picture ) ) {
720
- $fb_picture ? $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, $post_data->full_picture ) : '';
721
- } elseif ( ! empty( $post_data->picture ) ) {
722
- $fb_picture ? $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, $post_data->picture ) : '';
723
- }
724
-
725
- $fb_shortcode['words'] = isset( $fb_shortcode['words'] ) ? $fb_shortcode['words'] : '';
726
- // Description Wrap.
727
- echo '<div class="fts-jal-fb-description-wrap">';
728
- // Output Link Name.
729
- $fb_name ? $this->fts_facebook_post_name( $fb_link, $fb_name, $fb_type ) : '';
730
- if ( isset( $host ) && 'www.facebook.com' === $host && 'events' === $first_dir ) {
731
- echo ' &#9658; ';
732
- echo '<a href="' . esc_url( $fb_link ) . '" class="fts-jal-fb-name" target="_blank" rel="noreferrer">' . esc_html( $fb_link_event_name ) . '</a>';
733
- }//end if event.
734
- // Output Link Description.
735
- $fb_description ? $this->fts_facebook_post_desc( $fb_description, $fb_shortcode, $fb_type ) : '';
736
-
737
- // Output Link Caption.
738
- $fb_caption ? $this->fts_facebook_post_cap( $fb_caption, $fb_shortcode, $fb_type ) : '';
739
- echo '<div class="fts-clear"></div></div>';
740
- echo '<div class="fts-clear"></div></div>';
741
- break;
742
-
743
- // START VIDEO POST.
744
- case 'video':
745
- // $video_data = json_decode($response_post_array[$post_data_key . '_video']);.
746
- // echo '<pre>';.
747
- // print_r($video_data);.
748
- // echo '</pre>';.
749
- echo '<div class="fts-jal-fb-vid-wrap">';
750
-
751
- if ( ! empty( $fb_picture ) ) {
752
-
753
- // Create Dynamic Class Name.
754
- $fts_dynamic_vid_name_string = sanitize_key( $this->fts_rand_string( 10 ) . '_' . $fb_shortcode['type'] );
755
- $fts_dynamic_vid_name = 'feed_dynamic_video_class' . $fts_dynamic_vid_name_string;
756
- echo '<div class="fts-jal-fb-vid-picture ' . esc_html( $fts_dynamic_vid_name ) . '">';
757
-
758
- if ( strpos( $fb_video_embed, 'youtube' ) > 0 || strpos( $fb_video_embed, 'youtu.be' ) > 0 ) {
759
- preg_match( "/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:m\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&\"'>]+)/", $fb_video_embed, $matches );
760
- $video_url_final = 'https://www.youtube.com/watch?v=' . $matches[1];
761
- } else {
762
- $video_url_final = esc_url( $embed_html );
763
- }
764
-
765
- // This puts the video in a popup instead of displaying it directly on the page.
766
- if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ) {
767
-
768
- if ( strpos( $fb_link, 'youtube' ) > 0 || strpos( $fb_link, 'youtu.be' ) > 0 || strpos( $fb_link, 'vimeo' ) > 0 ) {
769
- echo '<a href="' . esc_url( $video_url_final ) . '" class="fts-facebook-link-target fts-jal-fb-vid-image fts-iframe-type">';
770
- } else {
771
-
772
- if ( 'video' === $post_data->type ) {
773
- $page_id = $post_data->from->id;
774
- $video_id = $post_data->object_id;
775
- $fb_embed_url = 'https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2F' . $page_id . '%2Fvideos%2F' . $video_id . '%2F&autoplay=true';
776
- echo '<a href="' . esc_url( $fb_embed_url ) . '" class="fts-jal-fb-vid-image ' . esc_attr( $fts_view_fb_videos_btn ) . ' fts-jal-fb-vid-html5video ">';
777
-
778
- } else {
779
- echo '<a href="' . esc_url( $embed_html ) . '" class="fts-facebook-link-target fts-jal-fb-vid-html5video ">';
780
- }
781
- }
782
- }
783
- // srl: 8/27/17 - FB BUG: for some reason the full_picture for animated gifs is not correct so we dig deeper and grab another image size fb has set.
784
- if ( isset( $post_data->attachments->data[0]->type ) && 'animated_image_video' === $post_data->attachments->data[0]->type ) {
785
- $vid_pic = $post_data->attachments->data[0]->media->image->src;
786
- } else {
787
- $vid_pic = $post_data->full_picture;
788
- }
789
- echo '<img class="fts-jal-fb-vid-image" border="0" alt="' . esc_attr( $post_data->from->name ) . '" src="' . esc_url( $vid_pic ) . '"/>';
790
-
791
- // This puts the video in a popup instead of displaying it directly on the page.
792
- if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ) {
793
- echo '</a>';
794
- }
795
-
796
- echo '<div class="fts-jal-fb-vid-play-btn"></div></div>';
797
-
798
- // If this is a facebook embed video then ouput Iframe and script.
799
- $embed_height = isset( $post_data->attachments->data[0]->media->image->height ) ? $post_data->attachments->data[0]->media->image->height : '';
800
- $embed_width = isset( $post_data->attachments->data[0]->media->image->width ) ? $post_data->attachments->data[0]->media->image->width : '';
801
- $video_type = isset( $post_data->type ) ? $post_data->type : '';
802
- $video_inline = isset( $post_data->attachments->data[0]->type ) ? $post_data->attachments->data[0]->type : '';
803
- // && $video_inline == 'video_inline'.
804
- if ( 'video' === $video_type && 'video_inline' === $video_inline || 'video' === $video_type && 'animated_image_video' === $video_inline ) {
805
-
806
- if ( $embed_height > $embed_width ) {
807
- $data_height = 'fts-greater-than-width-height';
808
- } elseif ( $embed_height === $embed_width ) {
809
- $data_height = 'fts-equal-width-height fts-fluid-videoWrapper ';
810
- } else {
811
- $data_height = 'fts-fluid-videoWrapper';
812
- }
813
-
814
- echo '<div class="fts-fb-embed-iframe-check-used-for-popup fts-fb-embed-yes">';
815
- if ( $embed_height >= $embed_width ) {
816
- echo '<div class=' . esc_attr( $data_height ) . ' data-width="' . esc_attr( $embed_width ) . '" data-height="' . esc_attr( $embed_height ) . '"></div>';
817
- }
818
- echo '</div>';
819
- // This puts the video on the page instead of the popup if you don't have the premium version.
820
- if ( ! isset( $fb_shortcode['popup'] ) || isset( $fb_shortcode['popup'] ) && 'yes' !== $fb_shortcode['popup'] && is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) || isset( $fb_shortcode['popup'] ) && empty( $fb_shortcode['popup'] ) || isset( $fb_shortcode['popup'] ) && 'no' === $fb_shortcode['popup'] ) {
821
-
822
- $page_id = isset( $post_data->from->id ) ? $post_data->from->id : '';
823
- $video_id = isset( $post_data->object_id ) ? $post_data->object_id : '';
824
-
825
- $fb_embed_url = 'https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2F' . $page_id . '%2Fvideos%2F' . $video_id . '%2F&autoplay=true';
826
-
827
- echo '<script>';
828
- echo 'jQuery(document).ready(function() {';
829
- echo 'jQuery(".' . esc_js( $fts_dynamic_vid_name ) . '").click(function() {';
830
- echo 'jQuery(this).addClass("fts-vid-div");';
831
- echo 'jQuery(this).removeClass("fts-jal-fb-vid-picture");';
832
- // echo 'jQuery(this).prepend(\'<div class="fts-fluid-videoWrapper"><iframe height="281" class="video'.$fb_post_id.'" src="http://www.youtube.com/embed/'.$youtubeURLfinal.'?autoplay=1" frameborder="0" allowfullscreen></iframe></div>\');';.
833
- echo 'jQuery(this).prepend(\'<div class="' . esc_js( $data_height ) . ' fts-fb-video-on-page" ><iframe style="background:none !important" class="video-' . esc_js( $fb_post_id ) . '" src="' . esc_url( $fb_embed_url ) . '" frameborder="0" allowfullscreen></iframe></div>\');';
834
- echo 'jQuery( ".' . esc_js( $fts_dynamic_vid_name ) . ' .fts-greater-than-width-height.fts-fb-video-on-page, .' . esc_js( $fts_dynamic_vid_name ) . ' iframe" ).css({"height": "' . esc_js( $embed_height ) . 'px", "width": "' . esc_js( $embed_width ) . 'px"});';
835
- if ( isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] || isset( $fb_shortcode['grid_combined'] ) && 'yes' === $fb_shortcode['grid_combined'] ) {
836
- echo 'jQuery(".fts-slicker-facebook-posts, .fts-mashup").masonry( "reloadItems");';
837
- echo 'jQuery(".fts-slicker-facebook-posts, .fts-mashup").masonry( "layout" );';
838
- }
839
- echo '});';
840
- echo '});';
841
- echo '</script>';
842
- }
843
- }
844
- // strip Youtube URL then ouput Iframe and script.
845
- if ( strpos( $fb_link, 'youtube' ) > 0 ) {
846
- // $pattern = '#^(?:https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com(?:/embed/|/v/|/watch\?v=|/watch\?.+&v=))([\w-]{11})(?:.+)?$#x';.
847
- // preg_match($pattern, $fb_link, $matches);.
848
- // $youtubeURLfinal = $matches[1];.
849
- // This puts the video on the page instead of the popup if you don't have the premium version.
850
- if ( ! isset( $fb_shortcode['popup'] ) || isset( $fb_shortcode['popup'] ) && 'yes' !== $fb_shortcode['popup'] && is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) || isset( $fb_shortcode['popup'] ) && empty( $fb_shortcode['popup'] ) || isset( $fb_shortcode['popup'] ) && 'no' === $fb_shortcode['popup'] ) {
851
- echo '<script>jQuery(document).ready(function() {';
852
- echo 'jQuery(".' . esc_js( $fts_dynamic_vid_name ) . '").click(function() {';
853
- echo 'jQuery(this).addClass("fts-vid-div");';
854
- echo 'jQuery(this).removeClass("fts-jal-fb-vid-picture");';
855
- // echo 'jQuery(this).prepend(\'<div class="fts-fluid-videoWrapper"><iframe height="281" class="video'.$fb_post_id.'" src="https://www.youtube.com/embed/'.$youtubeURLfinal.'?autoplay=1" frameborder="0" allowfullscreen></iframe></div>\');';.
856
- echo 'jQuery(this).prepend(\'<div class="fts-fluid-videoWrapper"><iframe height="281" class="video' . esc_js( $fb_post_id ) . '" src="' . esc_url( $fb_video_embed ) . '" frameborder="0" allowfullscreen></iframe></div>\');';
857
- if ( isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] || isset( $fb_shortcode['grid_combined'] ) && 'yes' === $fb_shortcode['grid_combined'] ) {
858
- echo 'jQuery(".fts-slicker-facebook-posts, .fts-mashup").masonry( "reloadItems");';
859
- echo 'jQuery(".fts-slicker-facebook-posts, .fts-mashup").masonry( "layout" );';
860
- }
861
- echo '});';
862
- echo '});</script>';
863
- }
864
- } elseif (
865
- // strip Youtube URL then ouput Iframe and script.
866
- strpos( $fb_link, 'youtu.be' ) > 0 ) {
867
- // $pattern = '#^(?:https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com(?:/embed/|/v/|/watch\?v=|/watch\?.+&v=))([\w-]{11})(?:.+)?$#x';.
868
- // preg_match($pattern, $fb_link, $matches);.
869
- // $youtubeURLfinal = $matches[1];.
870
- // This puts the video in a popup instead of displaying it directly on the page.
871
- if ( ! isset( $fb_shortcode['popup'] ) || isset( $fb_shortcode['popup'] ) && 'yes' !== $fb_shortcode['popup'] && is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) || isset( $fb_shortcode['popup'] ) && empty( $fb_shortcode['popup'] ) || isset( $fb_shortcode['popup'] ) && 'no' === $fb_shortcode['popup'] ) {
872
- echo '<script>';
873
- echo 'jQuery(document).ready(function() {';
874
- echo 'jQuery(".' . esc_js( $fts_dynamic_vid_name ) . '").click(function() {';
875
- echo 'jQuery(this).addClass("fts-vid-div");';
876
- echo 'jQuery(this).removeClass("fts-jal-fb-vid-picture");';
877
- // echo 'jQuery(this).prepend(\'<div class="fts-fluid-videoWrapper"><iframe height="281" class="video'.$fb_post_id.'" src="http://www.youtube.com/embed/'.$youtubeURLfinal.'?autoplay=1" frameborder="0" allowfullscreen></iframe></div>\');';.
878
- echo 'jQuery(this).prepend(\'<div class="fts-fluid-videoWrapper"><iframe height="281" class="video' . esc_js( $fb_post_id ) . '" src="' . esc_url( $fb_video_embed ) . '" frameborder="0" allowfullscreen></iframe></div>\');';
879
- if ( isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] || isset( $fb_shortcode['grid_combined'] ) && 'yes' === $fb_shortcode['grid_combined'] ) {
880
- echo 'jQuery(".fts-slicker-facebook-posts, .fts-mashup").masonry( "reloadItems");';
881
- echo 'jQuery(".fts-slicker-facebook-posts, .fts-mashup").masonry( "layout" );';
882
- }
883
- echo '});';
884
- echo '});';
885
- echo '</script>';
886
- }
887
- } elseif (
888
- // strip Vimeo URL then ouput Iframe and script.
889
- strpos( $fb_link, 'vimeo' ) > 0 ) {
890
- // $pattern = '/(\d+)/';.
891
- // preg_match($pattern, $fb_link, $matches);.
892
- // $vimeoURLfinal = $matches[0];.
893
- // This puts the video in a popup instead of displaying it directly on the page.
894
- if ( ! isset( $fb_shortcode['popup'] ) || isset( $fb_shortcode['popup'] ) && 'yes' !== $fb_shortcode['popup'] && is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) || isset( $fb_shortcode['popup'] ) && empty( $fb_shortcode['popup'] ) || isset( $fb_shortcode['popup'] ) && 'no' === $fb_shortcode['popup'] ) {
895
- echo '<script>';
896
- echo 'jQuery(document).ready(function() {';
897
- echo 'jQuery(".' . esc_js( $fts_dynamic_vid_name ) . '").click(function() {';
898
- echo 'jQuery(this).addClass("fts-vid-div");';
899
- echo 'jQuery(this).removeClass("fts-jal-fb-vid-picture");';
900
- // echo 'jQuery(this).prepend(\'<div class="fts-fluid-videoWrapper"><iframe src="http://player.vimeo.com/video/'.$vimeoURLfinal.'?autoplay=1" class="video'.$fb_post_id.'" height="390" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>\');';.
901
- echo 'jQuery(this).prepend(\'<div class="fts-fluid-videoWrapper"><iframe src="' . esc_url( $fb_video_embed ) . '" class="video' . esc_js( $fb_post_id ) . '" height="390" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>\');';
902
- if ( isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] || isset( $fb_shortcode['grid_combined'] ) && 'yes' === $fb_shortcode['grid_combined'] ) {
903
- echo 'jQuery(".fts-slicker-facebook-posts, .fts-mashup").masonry( "reloadItems");';
904
- echo 'jQuery(".fts-slicker-facebook-posts, .fts-mashup").masonry( "layout" );';
905
- }
906
- echo '});';
907
- echo '});';
908
- echo '</script>';
909
- }
910
- }
911
- }
912
- if ( $fb_name || $fb_caption || $fb_description ) {
913
- echo '<div class="fts-jal-fb-description-wrap fb-id' . esc_attr( $fb_post_id ) . '">';
914
- // Output Video Name.
915
- $fb_name ? $this->fts_facebook_post_name( $fb_link, $fb_name, $fb_type, $fb_post_id ) : '';
916
- // Output Video Description.
917
- $fb_description ? $this->fts_facebook_post_desc( $fb_description, $fb_shortcode, $fb_type, $fb_post_id ) : '';
918
- // Output Video Caption.
919
- $fb_caption ? $this->fts_facebook_post_cap( $fb_caption, $fb_shortcode, $fb_type, $fb_post_id ) : '';
920
- echo '<div class="fts-clear"></div></div>';
921
- }
922
- echo '<div class="fts-clear"></div></div>';
923
- break;
924
- // START PHOTO POST.
925
- case 'photo':
926
- if ( isset( $fts_hide_photos_type ) && 'yes' === $fts_hide_photos_type && 'album_photos' !== $fb_shortcode['type'] && 'yes' !== $fb_shortcode['video_album'] ) {
927
- break;
928
- }
929
-
930
- // Wrapping with if statement to prevent Notice on some facebook page feeds.
931
- if ( 'group' === $fb_shortcode['type'] ) {
932
- $photo_source = json_decode( $response_post_array[ $post_data_key . '_group_post_photo' ] );
933
- }
934
- // Group or page?
935
- $photo_source_final = isset( $post_data->full_picture ) ? $post_data->full_picture : 'https://graph.facebook.com/' . $fb_post_object_id . '/picture';
936
-
937
- echo '<div class="fts-jal-fb-link-wrap fts-album-photos-wrap"';
938
- if ( 'album_photos' === $fb_shortcode['type'] || 'albums' === $fb_shortcode['type'] ) {
939
- echo ' style="line-height:' . esc_attr( $fb_shortcode['image_height'] ) . ' !important;"';
940
- }
941
- echo '>';
942
- // echo isset($fb_shortcode['popup']) && $fb_shortcode['popup'] == 'yes' ? '<div class="fts-fb-caption"><a href="' . $fb_link . '" class="fts-view-on-facebook-link" target="_blank">' . esc_html('View on Facebook', 'feed-them-social') . '</a></div> ' : '';.
943
- // Output Photo Picture.
944
- if ( $fb_post_object_id ) {
945
- if ( $fb_post_object_id ) {
946
-
947
- // if we have more than one attachment we get the first image width and set that for the max width.
948
- $fts_fb_image_count = isset( $post_data->attachments->data[0]->subattachments->data ) ? count( $post_data->attachments->data[0]->subattachments->data ) : '0';
949
- // TESTING: lets see how many images are being output per post.
950
- // echo $fts_fb_image_count;.
951
- // echo $fts_fb_image_count;.
952
- if ( '0' === $fts_fb_image_count || '1' === $fts_fb_image_count || $fts_fb_image_count > 2 ) {
953
-
954
- // echo $fts_fb_image_count;.
955
- echo '<a href="' . ( isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ? esc_url( $photo_source_final ) : esc_url( $fb_link ) ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-picture fts-fb-large-photo"><img border="0" alt="' . esc_attr( $post_data->from->name ) . '" src="' . esc_url( $photo_source_final ) . '"></a>';
956
-
957
- }
958
-
959
- if ( '' !== $fb_picture_gallery1 ) {
960
-
961
- // we count the number of attachments in the subattachments->data portion of the array and count the objects http://php.net/manual/en/function.count.php.
962
- $fts_fb_image_counter = $fts_fb_image_count - 3;
963
-
964
- $fts_fb_image_count_check = $fts_fb_image_count < 3 ? ' fts-more-images-tint' : '';
965
-
966
- $fb_picture_gallery1_check = '' === $fb_picture_gallery2 ? '100%;' : $fb_picture_gallery0_width . 'px';
967
- // if we only have 2 photos we show them side by side.
968
- $fb_picture_gallery2_check = '' === $fb_picture_gallery2 ? ' fts-more-photos-auto-width' : '';
969
- // if we have 3 photos we add this class so we can make the 2 attachments below the large image will fit side by side.
970
- $fb_picture_gallery3_check = '' === $fb_picture_gallery3 && '' !== $fb_picture_gallery2 ? ' fts-more-photos-three-photo-wrap' : '';
971
-
972
- $columns_css = '';
973
-
974
- // print $fts_fb_image_count;.
975
- if ( 2 === $fts_fb_image_count ) {
976
- $columns = '2';
977
- $columns_css = 'fts-more-photos-2-or-3-photos ';
978
- $morethan3 = 'fts-2-photos ';
979
- } elseif ( 3 === $fts_fb_image_count ) {
980
- $columns = '2';
981
- $columns_css = 'fts-more-photos-2-or-3-photos ';
982
- $morethan3 = 'fts-3-photos ';
983
- } elseif ( $fts_fb_image_count >= 4 ) {
984
- $columns = '3';
985
- $columns_css = 'fts-more-photos-4-photos ';
986
- $morethan3 = 'fts-4-photos ';
987
- }
988
-
989
- echo '<div class="fts-clear"></div><div class="' . esc_attr( $columns_css . 'fts-fb-more-photos-wrap fts-facebook-inline-block-centered' . $fb_picture_gallery2_check . $fb_picture_gallery3_check ) . '" style="max-width:' . esc_attr( $fb_picture_gallery1_check ) . '" data-ftsi-id=' . esc_attr( $fts_dynamic_vid_name_string ) . ' data-ftsi-columns="' . esc_attr( $columns ) . '" data-ftsi-margin="1px" data-ftsi-force-columns="yes">';
990
- }
991
- if ( 2 === $fts_fb_image_count ) {
992
- echo '<a href="' . ( isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ? esc_url( $photo_source_final ) : esc_url( $fb_link ) ) . '" target="_blank" rel="noreferrer" class="slicker-facebook-placeholder fts-fb-thumbs-wrap ' . esc_attr( $morethan3 ) . 'fts-fb-thumb-zero-wrap fts-fb-large-photo" style="background:url(' . esc_url( $photo_source_final ) . ');" title="' . esc_attr( $fb_pictureGalleryDescription0 ) . '" aria-label="' . esc_attr( $fb_pictureGalleryDescription0 ) . '"></a>';
993
-
994
- }
995
- if ( '' !== $fb_picture_gallery1 ) {
996
- echo '<a href="' . ( isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ? esc_url( $fb_picture_gallery1 ) : esc_url( $fb_picture_gallery_link1 ) ) . '" target="_blank" rel="noreferrer" class="slicker-facebook-placeholder fts-fb-thumbs-wrap ' . esc_attr( $morethan3 ) . 'fts-fb-thumb-zero-wrap fts-fb-large-photo" style="background:url(' . esc_url( $fb_picture_gallery1 ) . ');" title="' . esc_attr( $fb_pictureGalleryDescription1 ) . '" aria-label="' . esc_attr( $fb_pictureGalleryDescription1 ) . '"></a>';
997
-
998
- if ( '' !== $fb_picture_gallery2 ) {
999
- echo '<a href="' . ( isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ? esc_url( $fb_picture_gallery2 ) : esc_url( $fb_picture_gallery_link2 ) ) . '" target="_blank" rel="noreferrer" class="fts-2-or-3-photos slicker-facebook-placeholder fts-fb-thumbs-wrap ' . esc_attr( $morethan3 ) . 'fts-fb-thumb-one-wrap fts-fb-large-photo" style="background:url(' . esc_url( $fb_picture_gallery2 ) . ');" title="' . esc_attr( $fb_pictureGalleryDescription1 ) . '" aria-label="' . esc_attr( $fb_pictureGalleryDescription1 ) . '"></a>';
1000
-
1001
- }
1002
- if ( '' !== $fb_picture_gallery3 ) {
1003
- echo '<a href="' . ( isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ? esc_url( $fb_picture_gallery3 ) : esc_url( $fb_picture_gallery_link3 ) ) . '" target="_blank" rel="noreferrer" class="slicker-facebook-placeholder fts-fb-thumbs-wrap ' . esc_attr( $morethan3 ) . 'fts-fb-thumb-two-wrap fts-fb-large-photo' . esc_attr( $fts_fb_image_count_check ) . '" style="background:url(' . esc_url( $fb_picture_gallery3 ) . ');" title="' . esc_attr( $fb_pictureGalleryDescription2 ) . '" aria-label="' . esc_attr( $fb_pictureGalleryDescription2 ) . '"><div class="fts-image-count-tint-underlay"></div><div class="fts-image-count"><span>+</span>' . esc_html( $fts_fb_image_counter ) . '</div></a>';
1004
- }
1005
- }
1006
- if ( '' !== $fb_picture_gallery1 ) {
1007
- echo '</div>';
1008
- }
1009
- } else {
1010
- echo '<a href="' . ( isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ? esc_url( $photo_source_final ) : esc_url( $fb_link ) ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-picture fts-fb-large-photo"><img border="0" alt="' . esc_attr( $post_data->from->name ) . '" src="' . esc_url( $photo_source_final ) . '" title="' . $fb_pictureGalleryDescription0 . '" aria-label="' . $fb_pictureGalleryDescription0 . '"></a>';
1011
- }
1012
- } elseif ( $fb_picture ) {
1013
- if ( $fb_post_object_id ) {
1014
- $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, 'https://graph.facebook.com/' . $fb_post_object_id . '/picture' );
1015
- } else {
1016
- echo isset( $fb_shortcode['video_album'] ) && 'yes' === $fb_shortcode['video_album'] ? $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, $video_photo ) : $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, $post_data->source );
1017
- }
1018
- }
1019
- echo '<div class="slicker-facebook-album-photoshadow"></div>';
1020
- // FB Video play button for facebook videos. This button takes data from our a tag and along with additional js in the magnific-popup.js we can now load html5 videos. SO lightweight this way because no pre-loading of videos are on the page. We only show the posterboard on mobile devices because tablets and desktops will auto load the videos. SRL.
1021
- if ( isset( $fb_shortcode['video_album'] ) && 'yes' === $fb_shortcode['video_album'] ) {
1022
- if ( isset( $fb_shortcode['play_btn'] ) && 'yes' === $fb_shortcode['play_btn'] ) {
1023
- $fb_play_btn_visible = isset( $fb_shortcode['play_btn_visible'] ) && 'yes' === $fb_shortcode['play_btn_visible'] ? ' visible-video-button' : '';
1024
-
1025
- // $post_data_source = isset($post_data->source) ? $post_data->source : $embed_html;.
1026
- // $post_data_source = isset($embed_html) ? $embed_html : '';.
1027
- // $post_data_format_3_picture = isset($post_data->format[3]->picture) ? $post_data->format[3]->picture : '';.
1028
- echo '<a href="' . esc_url( $embed_html ) . '" data-poster="" id="fts-view-vid1-' . esc_attr( $fts_dynamic_vid_name_string ) . '" title="' . esc_html( $fb_description ) . '" class="fts-jal-fb-vid-html5video ' . esc_attr( $fts_view_fb_videos_btn . ' fb-video-popup-' . $fts_dynamic_vid_name_string . ' ' . $fb_play_btn_visible ) . ' fts-slicker-backg" style="height:' . esc_attr( $fb_shortcode['play_btn_size'] ) . ' !important; width:' . esc_attr( $fb_shortcode['play_btn_size'] ) . '; line-height: ' . esc_attr( $fb_shortcode['play_btn_size'] ) . '; font-size:' . esc_attr( $fb_shortcode['play_btn_size'] ) . '"><span class="fts-fb-video-icon" style="height:' . esc_attr( $fb_shortcode['play_btn_size'] ) . '; width:' . esc_attr( $fb_shortcode['play_btn_size'] ) . '; line-height:' . esc_attr( $fb_shortcode['play_btn_size'] ) . '; font-size:' . esc_attr( $fb_shortcode['play_btn_size'] ) . '"></span></a>';
1029
-
1030
- echo '<div class="fts-fb-embed-iframe-check-used-for-popup fts-fb-embed-yes">';
1031
- if ( $embed_height >= $embed_width ) {
1032
- echo '<div class=' . esc_attr( $data_height ) . ' data-width="' . esc_attr( $embed_width ) . '" data-height="' . esc_attr( $embed_height ) . '"></div>';
1033
- }
1034
- echo '</div>';
1035
- }
1036
- }
1037
- if ( 'album_photos' === ! $fb_shortcode['type'] ) {
1038
- echo '<div class="fts-jal-fb-description-wrap" style="display:none">';
1039
- // Output Photo Name.
1040
- $fb_name ? $this->fts_facebook_post_name( $fb_link, $fb_name, $fb_type ) : '';
1041
- // Output Photo Caption.
1042
- $fb_caption ? $this->fts_facebook_post_cap( $fb_caption, $fb_shortcode, $fb_type ) : '';
1043
- // Output Photo Description.
1044
- $fb_description ? $this->fts_facebook_post_desc( $fb_description, $fb_shortcode, $fb_type, null, $fb_by ) : '';
1045
- echo '<div class="fts-clear"></div></div>';
1046
- }
1047
- echo '<div class="fts-clear"></div></div>';
1048
- break;
1049
-
1050
- // START ALBUM POST.
1051
- case 'app':
1052
- case 'cover':
1053
- case 'profile':
1054
- case 'mobile':
1055
- case 'wall':
1056
- case 'normal':
1057
- case 'album':
1058
- echo '<div class="fts-jal-fb-link-wrap fts-album-photos-wrap"';
1059
- if ( 'album_photos' === $fb_shortcode['type'] || 'albums' === $fb_shortcode['type'] ) {
1060
- echo ' style="line-height:' . esc_attr( $fb_shortcode['image_height'] ) . ' !important;"';
1061
- }
1062
- echo '>';
1063
-
1064
- // echo '<pre>rrr';
1065
- // print_r($fb_album_cover);
1066
- // echo '</pre>';
1067
- // Output Photo Picture.
1068
- $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, $fb_album_cover );
1069
- echo '<div class="slicker-facebook-album-photoshadow"></div>';
1070
- if ( 'albums' === ! $fb_shortcode['type'] ) {
1071
- echo '<div class="fts-jal-fb-description-wrap">';
1072
- // Output Photo Name.
1073
- $fb_name ? $this->fts_facebook_post_name( $fb_link, $fb_name, $fb_type ) : '';
1074
- // Output Photo Caption.
1075
- $fb_caption ? $this->fts_facebook_post_cap( $fb_caption, $fb_shortcode, $fb_type ) : '';
1076
- // Output Photo Description.
1077
- $fb_description ? $this->fts_facebook_post_desc( $fb_description, $fb_shortcode, $fb_type, null, $fb_by ) : '';
1078
- echo '<div class="fts-clear"></div></div>';
1079
- }
1080
- echo '<div class="fts-clear"></div></div>';
1081
- break;
1082
-
1083
- }
1084
- // This puts the video in a popup instead of displaying it directly on the page.
1085
- if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ) {
1086
- // Post Comments.
1087
- echo '<div class="fts-fb-comments-wrap">';
1088
- $hide_comments_popup = isset( $fb_shortcode['hide_comments_popup'] ) ? $fb_shortcode['hide_comments_popup'] : 'no';
1089
- if ( isset( $lcs_array['comments_thread']->data ) && ! empty( $lcs_array['comments_thread']->data ) && 'yes' !== $hide_comments_popup || isset( $lcs_array['comments_thread']->data ) && ! empty( $lcs_array['comments_thread']->data ) && empty( $hide_comments_popup ) ) {
1090
- // Post Comments.
1091
- echo '<div class="fts-fb-comments-content fts-comments-post-' . esc_attr( $fb_post_id ) . '">';
1092
-
1093
- foreach ( $lcs_array['comments_thread']->data as $comment ) {
1094
- if ( ! empty( $comment->message ) ) {
1095
- echo '<div class="fts-fb-comment fts-fb-comment-' . esc_attr( $comment->id ) . '">';
1096
- // User Profile Img.
1097
- // Not having page public content access persmission anymore is not allowing us to get profile pics anymore, and the link to personal accounts won't work anymore either for people posting to our page.
1098
- // $avatar_id = isset( $comment->from->id ) ? 'https://graph.facebook.com/'.$comment->from->id.'/picture?redirect=1&type=square' : plugin_dir_url( dirname( __FILE__ ) ) . 'images/slick-comment-pic.png';
1099
- $avatar_id = plugin_dir_url( __DIR__ ) . 'images/slick-comment-pic.png';
1100
- echo '<img class="fts-fb-comment-user-pic" src="' . esc_url( $avatar_id ) . '"/>';
1101
- echo '<div class="fts-fb-comment-msg">';
1102
- if ( isset( $comment->from->name ) ) {
1103
- echo '<span class="fts-fb-comment-user-name">' . esc_html( $comment->from->name ) . '</span> ';
1104
- }
1105
- echo esc_html( $comment->message ) . '</div>';
1106
-
1107
- // Comment Message.
1108
- echo '</div>';
1109
- }
1110
- }
1111
- echo '</div>';
1112
-
1113
- // echo '<pre>';
1114
- // print_r( $lcs_array['comments_thread']->data );
1115
- // echo '</pre>';
1116
- }
1117
- echo '</div><!-- END Comments Wrap -->';
1118
- }
1119
-
1120
- // filter messages to have urls.
1121
- // Output Message For combined feeds in the bottom.
1122
- if ( isset( $fb_shortcode['show_media'] ) && 'top' === $show_media ) {
1123
-
1124
- if ( isset( $fb_shortcode['show_social_icon'] ) && 'right' === $fb_shortcode['show_social_icon'] ) {
1125
- echo '<div class="fts-mashup-icon-wrap-right fts-mashup-facebook-icon"><a href="' . esc_url( 'https://www.facebook.com/' . $from_id_picture ) . '" target="_blank" rel="noreferrer"></a></div>';
1126
- }
1127
- // show icon.
1128
- if ( isset( $fb_shortcode['show_social_icon'] ) && 'left' === $fb_shortcode['show_social_icon'] ) {
1129
- echo '<div class="fts-mashup-icon-wrap-left fts-mashup-facebook-icon"><a href="' . esc_url( 'https://www.facebook.com/' . $from_id_picture ) . '" target="_blank" rel="noreferrer"></a></div>';
1130
- }
1131
- echo '<div class="fts-jal-fb-top-wrap ' . esc_attr( $hide_date_likes_comments ) . '" style="display:block !important;">';
1132
- echo '<div class="fts-jal-fb-user-thumb">';
1133
-
1134
- $avatar_id = plugin_dir_url( __DIR__ ) . 'images/slick-comment-pic.png';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1135
  $profile_photo_exists_check = isset( $post_data->fts_profile_pic_url ) && strpos( $post_data->fts_profile_pic_url, 'profilepic' ) !== false ? $post_data->fts_profile_pic_url : $avatar_id;
1136
- echo ( 'reviews' === esc_attr( $fb_shortcode['type'] ) ? '' : '<a href="' . esc_url( 'https://www.facebook.com/' . $from_id_picture ) . '" target="_blank" rel="noreferrer">' ) . '<img border="0" alt="' . ( 'reviews' === esc_attr( $fb_shortcode['type'] ) ? esc_attr( $post_data->reviewer->name ) : esc_attr( $post_data->from->name ) ) . '" src="' . ( 'reviews' === esc_attr( $fb_shortcode['type'] ) ? esc_url( $profile_photo_exists_check ) . '"/>' : 'https://graph.facebook.com/' . esc_attr( $from_id_picture ) ) . ( 'reviews' === esc_attr( $fb_shortcode['type'] ) ? '' : '/picture"/></a>' );
1137
  echo '</div>';
1138
 
1139
- // UserName.
1140
- echo '<span class="fts-jal-fb-user-name"><a href="' . esc_url( 'https://www.facebook.com/' . $from_id_picture ) . '" target="_blank" rel="noreferrer">' . esc_html( $post_data->from->name ) . '</a>' . esc_html( $fb_hide_shared_by_etc_text ) . '</span>';
1141
-
1142
- // tied to date function.
1143
- $feed_type = 'facebook';
1144
- $times = $custom_time_format;
1145
- $fts_final_date = $this->fts_custom_date( $times, $feed_type );
1146
- // PostTime.
1147
- echo '<span class="fts-jal-fb-post-time">' . $fts_final_date . '</span><div class="fts-clear"></div>';
1148
-
1149
- if ( ! empty( $fb_places_id ) ) {
1150
- $this->feed_location_option( $fb_places_id, $fb_name, $fb_places_name );
1151
- }
1152
-
1153
- // here we trim the words for the premium version. The $fb_shortcode['words'] string actually comes from the javascript.
1154
- if ( is_plugin_active( 'feed-them-social-combined-streams/feed-them-social-combined-streams.php' ) && array_key_exists( 'words', $fb_shortcode ) || is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && array_key_exists( 'words', $fb_shortcode ) ) {
1155
- $more = isset( $more ) ? $more : '';
1156
- $trimmed_content = $this->fts_custom_trim_words( $fb_message, $fb_shortcode['words'], $more );
1157
-
1158
- echo '<div class="fts-jal-fb-message">';
1159
-
1160
- echo esc_html( $fb_title_job_opening );
1161
- echo ! empty( $trimmed_content ) ? $trimmed_content : '';
1162
- echo '<div class="fts-clear"></div></div> ';
1163
-
1164
- } else {
1165
- $fb_final_message = $this->fts_facebook_tag_filter( $fb_message );
1166
- echo '<div class="fts-jal-fb-message">';
1167
- echo nl2br( $fb_final_message );
1168
- echo '<div class="fts-clear"></div></div>';
1169
- }
1170
- echo '</div>';
1171
-
1172
- }
1173
-
1174
- echo '<div class="fts-clear"></div>';
1175
- echo '</div>';
1176
- $fb_post_single_id = isset( $fb_post_single_id ) ? $fb_post_single_id : '';
1177
- $single_event_id = isset( $single_event_id ) ? $single_event_id : '';
1178
- $this->fts_facebook_post_see_more( $fb_link, $lcs_array, $fb_type, $fb_post_id, $fb_shortcode, $fb_post_user_id, $fb_post_single_id, $single_event_id, $post_data );
1179
- echo '<div class="fts-clear"></div>';
1180
- echo '</div>';
1181
-
1182
- }//end feed_post_types()
1183
- }//end class
9
  class FTS_Facebook_Feed_Post_Types extends FTS_Facebook_Feed {
10
 
11
 
12
+ /**
13
+ * Feed Location Option
14
+ *
15
+ * Display Location flag and text
16
+ *
17
+ * @param string $fb_places_id The ID.
18
+ * @param string $fb_name The facebook page name.
19
+ * @param string $fb_places_name The location name.
20
+ * @since 1.9.6
21
+ */
22
+ public function feed_location_option( $fb_places_id, $fb_name, $fb_places_name ) {
23
+ echo '<div class="fts-fb-location-wrap">';
24
+ echo '<div class="fts-fb-location-img"></div>';
25
+ echo '<a href="' . esc_url( 'https://www.facebook.com/' . $fb_places_id . '/' ) . '" class="fts-fb-location-link" target="_blank" rel="noreferrer">' . esc_attr( $fb_name ) . '</a>';
26
+ echo '<div class="fts-fb-location-name">' . esc_html( $fb_places_name ) . '</div>';
27
+ echo '</div>';
28
+ }
29
+ /**
30
+ * Feed Post Types
31
+ *
32
+ * Display Facebook Feed.
33
+ *
34
+ * @param string $set_zero A way to skip posts.
35
+ * @param string $fb_type The type of Facebook Feed.
36
+ * @param string $post_data All post info.
37
+ * @param string $fb_shortcode All shortcode options picked.
38
+ * @param string $response_post_array All post info.
39
+ * @param string $single_event_array_response All post info.
40
+ * @since 1.9.6
41
+ */
42
+ public function feed_post_types( $set_zero, $fb_type, $post_data, $fb_shortcode, $response_post_array, $single_event_array_response = null ) {
43
+
44
+ // echo '<pre>';
45
+ // print_r($lcs_array);
46
+ // echo '</pre>';
47
+ // echo 'ASDF';
48
+ // Reviews Plugin.
49
+ if ( is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) ) {
50
+ $fts_facebook_reviews = new FTS_Facebook_Reviews();
51
+ }
52
+
53
+ $fts_dynamic_vid_name_string = sanitize_key( $this->fts_rand_string( 10 ) . '_' . $fb_shortcode['type'] );
54
+
55
+ if ( $set_zero === $fb_shortcode['posts'] ) {
56
+ return;
57
+ }
58
+ // Create Facebook Variables.
59
+ $fb_final_story = '';
60
+ $first_dir = '';
61
+ $fb_picture = isset( $post_data->picture ) ? $post_data->picture : '';
62
+ $fb_link = isset( $post_data->attachments->data[0]->url ) ? $post_data->attachments->data[0]->url : '';
63
+ $fb_name = isset( $post_data->name ) ? $post_data->name : '';
64
+ $fb_caption = isset( $post_data->attachments->data[0]->caption ) ? $post_data->attachments->data[0]->caption : '';
65
+ $fb_description = isset( $post_data->attachments->data[0]->description ) ? $post_data->attachments->data[0]->description : '';
66
+ $fb_link_event_name = isset( $post_data->to->data[0]->name ) ? $post_data->to->data[0]->name : '';
67
+ $fb_story = isset( $post_data->story ) ? $post_data->story : '';
68
+ $fb_icon = isset( $post_data->icon ) ? $post_data->icon : '';
69
+ $fb_by = isset( $post_data->properties->text ) ? $post_data->properties->text : '';
70
+ $fb_bylink = isset( $post_data->properties->href ) ? $post_data->properties->href : '';
71
+ $fb_post_share_count = isset( $post_data->shares->count ) ? $post_data->shares->count : '';
72
+ $fb_post_like_count_array = isset( $post_data->likes->data ) ? $post_data->likes->data : '';
73
+ $fb_post_comments_count_array = isset( $post_data->comments->data ) ? $post_data->comments->data : '';
74
+ $fb_post_object_id = isset( $post_data->attachments->data[0]->id ) ? $post_data->attachments->data[0]->id : '';
75
+ $fb_album_photo_count = isset( $post_data->count ) ? $post_data->count : '';
76
+ $fb_album_cover = isset( $post_data->photos->data[0]->images[0]->source ) ? $post_data->photos->data[0]->images[0]->source : '';
77
+ $fb_album_picture = isset( $post_data->source ) ? $post_data->source : '';
78
+ $fb_places_name = isset( $post_data->place->name ) ? $post_data->place->name : '';
79
+ $fb_places_id = isset( $post_data->place->id ) ? $post_data->place->id : '';
80
+
81
+ $fb_attachments_title = isset( $post_data->attachments->data[0]->title ) ? $post_data->attachments->data[0]->title : '';
82
+ $fb_attachments = isset( $post_data->attachments ) ? $post_data->attachments : '';
83
+ $fb_picture_job = isset( $post_data->attachments->data[0]->media->image->src ) ? $post_data->attachments->data[0]->media->image->src : '';
84
+ // youtube and vimeo embed url.
85
+ $fb_video_embed = isset( $post_data->attachments->data[0]->media->source ) ? $post_data->attachments->data[0]->media->source : '';
86
+
87
+ $fb_post_from_id = isset( $post_data->from->id ) ? $post_data->from->id : '';
88
+ $from_id_picture = $fb_post_from_id !== $fb_shortcode['id'] ? $fb_shortcode['id'] : $fb_post_from_id;
89
+
90
+ // if (isset($post_data->format[1]->picture)) {.
91
+ // $video_photo = $post_data->format[1]->picture;.
92
+ // } elseif (isset($post_data->format[0]->picture)) {.
93
+ // $video_photo = $post_data->format[0]->picture;.
94
+ // } else {.
95
+ // $video_photo = $post_data->picture;.
96
+ // }.
97
+ if ( isset( $post_data->format[3]->picture ) ) {
98
+ $video_photo = $post_data->format[3]->picture;
99
+ } elseif ( isset( $post_data->format[2]->picture ) ) {
100
+ $video_photo = $post_data->format[2]->picture;
101
+ } elseif ( isset( $post_data->format[1]->picture ) ) {
102
+ $video_photo = $post_data->format[1]->picture;
103
+ } elseif ( isset( $post_data->format[0]->picture ) ) {
104
+ $video_photo = $post_data->format[0]->picture;
105
+ } else {
106
+ $video_photo = '';
107
+ }
108
+
109
+ if ( ! empty( $post_data->format[3]->height ) && '0' !== $post_data->format[3]->height ) {
110
+ $embed_html = $post_data->format[3]->embed_html;
111
+
112
+ $embed_width = $post_data->format[3]->width;
113
+ $embed_height = $post_data->format[3]->height;
114
+ } elseif ( ! empty( $post_data->format[2]->height ) && '0' !== $post_data->format[2]->height ) {
115
+ $embed_html = $post_data->format[2]->embed_html;
116
+ $embed_width = $post_data->format[2]->width;
117
+ $embed_height = $post_data->format[2]->height;
118
+ } elseif ( ! empty( $post_data->format[1]->height ) && '0' !== $post_data->format[1]->height ) {
119
+ $embed_html = $post_data->format[1]->embed_html;
120
+ $embed_width = $post_data->format[1]->width;
121
+ $embed_height = $post_data->format[1]->height;
122
+ } elseif ( ! empty( $post_data->format[0]->height ) && '0' !== $post_data->format[0]->height ) {
123
+ $embed_html = $post_data->format[0]->embed_html;
124
+ $embed_width = $post_data->format[0]->width;
125
+ $embed_height = $post_data->format[0]->height;
126
+ } else {
127
+ $embed_html = 'none';
128
+ $embed_width = '';
129
+ $embed_height = '';
130
+ }
131
+
132
+ // This will take our embed iframe from the array and then strip out the src url for the iframe so we can.
133
+ // add this to our maginific popup.
134
+ if ( 'none' !== $embed_html ) {
135
+ preg_match( '/src="([^"]+)"/', $embed_html, $match );
136
+
137
+ $embed_html = $match[1] . '&autoplay=true';
138
+ // we do this check so we can add a data-height class name for our popup to know that we need to add the height to the iframe.
139
+ // otherwise we let the magnific pop up scaler class do the work.
140
+ if ( $embed_height > $embed_width ) {
141
+ $data_height = 'fts-greater-than-width-height';
142
+ } elseif ( $embed_height === $embed_width ) {
143
+ $data_height = 'fts-equal-width-height';
144
+ } else {
145
+ $data_height = '';
146
+ }
147
+ // fts-view-fb-videos-btn.
148
+ $fts_view_fb_videos_btn = 'fts-view-fb-videos-btn';
149
+
150
+ } else {
151
+ $embed_html = $video_photo;
152
+ $fts_view_fb_videos_btn = '';
153
+ $data_height = '';
154
+ }
155
+
156
+ $fb_video = isset( $post_data->embed_html ) ? $post_data->embed_html : '';
157
+ $fb_video_picture = isset( $post_data->format[2]->picture ) ? $post_data->format[2]->picture : '';
158
+
159
+ if ( $fb_album_cover ) {
160
+ // $photo_data = json_decode( $response_post_array[ $fb_album_cover . '_photo' ] );
161
+ }
162
+ if ( isset( $post_data->id ) ) {
163
+ $fb_post_id = $post_data->id;
164
+ $fb_post_full_id = explode( '_', $fb_post_id );
165
+ if ( isset( $fb_post_full_id[0] ) ) {
166
+ $fb_post_user_id = $fb_post_full_id[0];
167
+ }
168
+ if ( isset( $fb_post_full_id[1] ) ) {
169
+ $fb_post_single_id = $fb_post_full_id[1];
170
+ } else {
171
+ $fb_post_single_id = '';
172
+ }
173
+ } else {
174
+ $fb_post_id = '';
175
+ $fb_post_user_id = '';
176
+ }
177
+
178
+ $fb_joblink = isset( $post_data->id, $post_data->from->id ) ? 'https://www.facebook.com/' . $post_data->from->id . '/posts/' . $fb_post_single_id . '' : '';
179
+
180
+ if ( 'albums' === $fb_shortcode['type'] && ! $fb_album_cover ) {
181
+ unset( $post_data );
182
+ }
183
+ // Create Post Data Key.
184
+ if ( isset( $post_data->attachments->data[0]->object_id ) ) {
185
+ $post_data_key = $post_data->attachments->data[0]->object_id;
186
+ } else {
187
+ $post_data_key = isset( $post_data->id ) ? $post_data->id : '';
188
+ }
189
+ // Count Likes/Shares/.
190
+ $lcs_array = $this->get_likes_shares_comments( $response_post_array, $post_data_key, $fb_post_share_count );
191
+
192
+ // echo '<pre>';
193
+ // print_r($fb_post_share_count);
194
+ // echo '</pre>';
195
+
196
+ // $fb_location = isset( $post_data->location ) ? $post_data->location : '';
197
+ $fb_embed_vid = isset( $post_data->embed_html ) ? $post_data->embed_html : '';
198
+ $fb_from_name = isset( $post_data->from->name ) ? $post_data->from->name : '';
199
+ $fb_from_name = preg_quote( $fb_from_name, '/' );
200
+
201
+ $fb_story = isset( $post_data->story ) ? $post_data->story : '';
202
+ $fts_custom_date = get_option( 'fts-custom-date' ) ? get_option( 'fts-custom-date' ) : '';
203
+ $fts_custom_time = get_option( 'fts-custom-time' ) ? get_option( 'fts-custom-time' ) : '';
204
+ $custom_date_check = get_option( 'fts-date-and-time-format' ) ? get_option( 'fts-date-and-time-format' ) : '';
205
+
206
+ $fb_picture_gallery1 = isset( $post_data->attachments->data[0]->subattachments->data[1]->media->image->src ) ? $post_data->attachments->data[0]->subattachments->data[1]->media->image->src : '';
207
+ $fb_picture_gallery2 = isset( $post_data->attachments->data[0]->subattachments->data[2]->media->image->src ) ? $post_data->attachments->data[0]->subattachments->data[2]->media->image->src : '';
208
+ $fb_picture_gallery3 = isset( $post_data->attachments->data[0]->subattachments->data[3]->media->image->src ) ? $post_data->attachments->data[0]->subattachments->data[3]->media->image->src : '';
209
+
210
+ // we get the width of the first attachment so we can set the max width for the frame around the main image and thumbs.. this makes it so our percent width on thumbnails are nice and aligned.
211
+ $fb_picture_gallery0_width = isset( $post_data->attachments->data[0]->subattachments->data[0]->media->image->src ) ? $post_data->attachments->data[0]->subattachments->data[0]->media->image->width : '';
212
+
213
+ // June 22, 2017 - Going to leave the attachments description idea for a future update, lots more work to get the likes and comments for attachments and have that info be in the popup.
214
+ // $fb_pictureGalleryDescription0 = isset($post_data->attachments->data[0]->subattachments->data[1]->description) ? $post_data->attachments->data[0]->subattachments->data[1]->media->image->src : '';.
215
+ // $fb_pictureGalleryDescription1 = isset($post_data->attachments->data[0]->subattachments->data[2]->description)? $post_data->attachments->data[0]->subattachments->data[2]->media->image->src : '';.
216
+ // $fb_pictureGalleryDescription2 = isset($post_data->attachments->data[0]->subattachments->data[3]->description) ? $post_data->attachments->data[0]->subattachments->data[3]->media->image->src : '';.
217
+ // KZeni Edit: https://github.com/KZeni
218
+ // February 25, 2019 - Uncommented Description variables so they can be used when making it so the pictures meet accessibility standards.
219
+ $picture_from_fb = __( 'Picture from Facebook', 'feed-them-social' );
220
+ $fb_pictureGalleryDescription0 = isset( $post_data->attachments->data[0]->subattachments->data[1]->description ) ? $post_data->attachments->data[0]->subattachments->data[1]->description : $picture_from_fb;
221
+ $fb_pictureGalleryDescription1 = isset( $post_data->attachments->data[0]->subattachments->data[2]->description ) ? $post_data->attachments->data[0]->subattachments->data[2]->description : $picture_from_fb;
222
+ $fb_pictureGalleryDescription2 = isset( $post_data->attachments->data[0]->subattachments->data[3]->description ) ? $post_data->attachments->data[0]->subattachments->data[3]->description : $picture_from_fb;
223
+
224
+ $fb_picture_gallery_link1 = isset( $post_data->attachments->data[0]->subattachments->data[1]->target->url ) ? $post_data->attachments->data[0]->subattachments->data[1]->target->url : '';
225
+ $fb_picture_gallery_link2 = isset( $post_data->attachments->data[0]->subattachments->data[2]->target->url ) ? $post_data->attachments->data[0]->subattachments->data[2]->target->url : '';
226
+ $fb_picture_gallery_link3 = isset( $post_data->attachments->data[0]->subattachments->data[3]->target->url ) ? $post_data->attachments->data[0]->subattachments->data[3]->target->url : '';
227
+
228
+ if ( isset( $fb_shortcode['scrollhorz_or_carousel'], $fb_shortcode['slider_spacing'] ) && ! empty( $fb_shortcode['slider_spacing'] ) && 'carousel' === $fb_shortcode['scrollhorz_or_carousel'] ) {
229
+
230
+ $fb_shortcode['space_between_photos'] = '0 ' . $fb_shortcode['slider_spacing'];
231
+
232
+ }
233
+
234
+ if ( empty( $fts_custom_date ) && empty( $fts_custom_time ) && 'fts-custom-date' !== $custom_date_check ) {
235
+ $custom_date_format = $custom_date_check;
236
+ } elseif ( ! empty( $fts_custom_date ) && 'fts-custom-date' === $custom_date_check || ! empty( $fts_custom_time ) && 'fts-custom-date' === $custom_date_check ) {
237
+ $custom_date_format = $fts_custom_date . ' ' . $fts_custom_time;
238
+ } else {
239
+ $custom_date_format = 'F jS, Y \a\t g:ia';
240
+ }
241
+
242
+ $album_created_time = isset( $post_data->photos->data[0]->created_time ) ? $post_data->photos->data[0]->created_time : '';
243
+ $other_created_time = isset( $post_data->created_time ) ? $post_data->created_time : '';
244
+ $created_time = '' !== $album_created_time ? $album_created_time : $other_created_time;
245
+ $custom_time_format = strtotime( $created_time );
246
+
247
+ if ( ! empty( $fb_story ) ) {
248
+ $fb_final_story = preg_replace( '/\b' . $fb_from_name . 's*?\b(?=([^"]*"[^"]*")*[^"]*$)/i', '', $fb_story, 1 );
249
+ }
250
+
251
+ $fts_hide_photos_type = get_option( 'fb_hide_images_in_posts' ) ? get_option( 'fb_hide_images_in_posts' ) : 'no';
252
+
253
+ if ( strpos( $fb_link, 'youtube' ) > 0 || strpos( $fb_link, 'youtu.be' ) > 0 || strpos( $fb_link, 'vimeo' ) > 0 ) {
254
+ $fb_type = 'video_inline';
255
+ }
256
+ switch ( $fb_type ) {
257
+ case 'video_direct_response' :
258
+ case 'video_inline' :
259
+ echo '<div class="fts-jal-single-fb-post fts-fb-video-post-wrap" ';
260
+ if ( isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] ) {
261
+ echo 'style="width:' . esc_attr( $fb_shortcode['colmn_width'] ) . '!important; margin:' . esc_attr( $fb_shortcode['space_between_posts'] ) . '!important"';
262
+ }
263
+ echo '>';
264
+
265
+ break;
266
+ case 'app':
267
+ case 'cover':
268
+ case 'profile':
269
+ case 'mobile':
270
+ case 'wall':
271
+ case 'normal':
272
+ case 'photo':
273
+ echo "<div class='fts-fb-photo-post-wrap fts-jal-single-fb-post' ";
274
+ if ( 'album_photos' === $fb_shortcode['type'] || 'albums' === $fb_shortcode['type'] ) {
275
+
276
+ if ( isset( $fb_shortcode['scrollhorz_or_carousel'] ) && 'scrollhorz' === $fb_shortcode['scrollhorz_or_carousel'] ) {
277
+ echo 'style="max-width:' . esc_attr( $fb_shortcode['image_width'] ) . ';height:100%; margin:' . esc_attr( $fb_shortcode['space_between_photos'] ) . '!important"';
278
+ } else {
279
+ echo 'style="width:' . esc_attr( $fb_shortcode['image_width'] ) . ' !important; height:' . esc_attr( $fb_shortcode['image_height'] ) . '!important; margin:' . esc_attr( $fb_shortcode['space_between_photos'] ) . '!important"';
280
+ }
281
+ }
282
+ if ( isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] ) {
283
+ echo 'style="width:' . esc_attr( $fb_shortcode['colmn_width'] ) . '!important; margin:' . esc_attr( $fb_shortcode['space_between_posts'] ) . '!important"';
284
+ }
285
+ echo '>';
286
+
287
+ break;
288
+ case 'album':
289
+ default:
290
+ echo '<div class="fts-jal-single-fb-post"';
291
+ if ( isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] ) {
292
+ echo 'style="width:' . esc_attr( $fb_shortcode['colmn_width'] ) . '!important; margin:' . esc_attr( $fb_shortcode['space_between_posts'] ) . '!important"';
293
+ }
294
+ echo '>';
295
+ break;
296
+ }
297
+ // output Single Post Wrap.
298
+ // Don't echo if Events Feed.
299
+ if ( 'events' !== $fb_shortcode['type'] ) {
300
+
301
+ // Reviews.
302
+ $itemscope_reviews = 'reviews' === $fb_shortcode['type'] && isset( $post_data->rating ) ? 'itemscope itemtype="http://schema.org/Review"' : '';
303
+
304
+ // Right Wrap.
305
+ // $review_rating CANNOT be esc at this time.
306
+ echo '<div ' . esc_attr( $itemscope_reviews ) . ' class="fts-jal-fb-right-wrap">';
307
+ if ( 'reviews' === $fb_shortcode['type'] && isset( $post_data->rating ) ) {
308
+ echo '<meta itemprop="itemReviewed" itemscope itemtype="http://schema.org/CreativeWork"><div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" style="display: none;"><meta itemprop="worstRating" content = "1"><meta itemprop="ratingValue" content = "' . esc_attr( $post_data->rating ) . '"><meta itemprop="bestRating" content = "5"></div>';
309
+ }
310
+ // Top Wrap (Excluding : albums, album_photos, and hiding).
311
+ $hide_date_likes_comments = 'album_photos' === $fb_shortcode['type'] && 'yes' === $fb_shortcode['hide_date_likes_comments'] || 'albums' === $fb_shortcode['type'] && 'yes' === $fb_shortcode['hide_date_likes_comments'] ? 'hide-date-likes-comments-etc' : '';
312
+
313
+ $show_media = isset( $fb_shortcode['show_media'] ) ? $fb_shortcode['show_media'] : 'bottom';
314
+
315
+ if ( 'top' !== $show_media ) {
316
+ echo '<div class="fts-jal-fb-top-wrap ' . esc_attr( $hide_date_likes_comments ) . '">';
317
+ }
318
+ // if ($fb_shortcode['type'] == 'album_photos' || $fb_shortcode['type'] == 'albums') {.
319
+ // } else {.
320
+ // User Thumbnail.
321
+ $fb_hide_shared_by_etc_text = get_option( 'fb_hide_shared_by_etc_text' );
322
+ $fb_hide_shared_by_etc_text = isset( $fb_hide_shared_by_etc_text ) && 'no' === $fb_hide_shared_by_etc_text ? '' : $fb_final_story;
323
+
324
+ if ( 'top' !== $show_media ) {
325
+
326
+ if ( 'albums' !== $fb_shortcode['type'] ) {
327
+ echo '<div class="fts-jal-fb-user-thumb">';
328
+
329
+ $avatar_id = plugin_dir_url( __DIR__ ) . 'images/slick-comment-pic.png';
330
+ $profile_photo_exists_check = isset( $post_data->fts_profile_pic_url ) && strpos( $post_data->fts_profile_pic_url, 'profilepic' ) !== false ? $post_data->fts_profile_pic_url : $avatar_id;
331
+
332
+ echo ( 'reviews' === esc_attr( $fb_shortcode['type'] ) ? '' : '<a href="https://www.facebook.com/' . esc_attr( $from_id_picture ) . '" target="_blank" rel="noreferrer">' ) . '<img border="0" alt="' . ( 'reviews' === esc_attr( $fb_shortcode['type'] ) ? esc_attr( $post_data->reviewer->name ) : esc_attr( $post_data->from->name ) ) . '" src="' . ( 'reviews' === esc_attr( $fb_shortcode['type'] ) ? esc_url( $profile_photo_exists_check ) . '"/>' : 'https://graph.facebook.com/' . esc_attr( $from_id_picture ) ) . ( 'reviews' === esc_attr( $fb_shortcode['type'] ) ? '' : '/picture"/></a>' );
333
+
334
+ echo '</div>';
335
+
336
+ }
337
+
338
+ // UserName.
339
+ // $fts_facebook_reviews->reviews_rating_format CANNOT be esc at this time.
340
+ $hide_name = 'albums' === $fb_shortcode['type'] ? ' fts-fb-album-hide' : '';
341
+
342
+ echo ( 'reviews' === $fb_shortcode['type'] && is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) ? '<span class="fts-jal-fb-user-name fts-review-name" itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">' . esc_attr( $post_data->reviewer->name ) . '</span>' . $fts_facebook_reviews->reviews_rating_format( $fb_shortcode, isset( $post_data->rating ) ? esc_html( $post_data->rating ) : '' ) . '</span>' : '<span class="fts-jal-fb-user-name' . $hide_name . '"><a href="https://www.facebook.com/' . esc_attr( $from_id_picture ) . '" target="_blank" rel="noreferrer">' . esc_html( $post_data->from->name ) . '</a>' . esc_html( $fb_hide_shared_by_etc_text ) . '</span>' );
343
+
344
+ // tied to date function.
345
+ $feed_type = 'facebook';
346
+ $times = $custom_time_format;
347
+ $fts_final_date = $this->fts_custom_date( $times, $feed_type );
348
+ // PostTime.
349
+ // $fts_final_date CANNOT be esc at this time.
350
+ if ( 'albums' !== $fb_shortcode['type'] ) {
351
+ echo '<span class="fts-jal-fb-post-time">' . $fts_final_date . '</span><div class="fts-clear"></div>';
352
+ }
353
+ }
354
+
355
+ if ( 'reviews' !== $fb_shortcode['type'] ) {
356
+ // Comments Count.
357
+ $fb_post_id_final = substr( $fb_post_id, strpos( $fb_post_id, '_' ) + 1 );
358
+ }
359
+
360
+ $fb_title_job_opening = isset( $post_data->attachments->data[0]->title ) && 'job_search_job_opening' === $post_data->attachments->data[0]->type ? $post_data->attachments->data[0]->title : '';
361
+
362
+ // filter messages to have urls.
363
+ // Output Message.
364
+ $fb_message = ( isset( $post_data->message ) ? $post_data->message : ( isset( $post_data->review_text ) ? $post_data->review_text : '' ) . '' );
365
+ if ( empty( $fb_message ) ) {
366
+
367
+ if ( isset( $post_data->description ) ) {
368
+ $fb_message = isset( $post_data->description ) ? $post_data->description : '';
369
+ } elseif ( isset( $post_data->attachments->data[0]->description ) ) {
370
+ $fb_message = isset( $post_data->attachments->data[0]->description ) ? $post_data->attachments->data[0]->description : '';
371
+ }
372
+ }
373
+
374
+ if ( $fb_message && 'top' !== $show_media ) {
375
+
376
+ if ( ! empty( $fb_places_id ) ) {
377
+ $this->feed_location_option( $fb_places_id, $fb_name, $fb_places_name );
378
+ }
379
+
380
+ $itemprop_description_reviews = is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) ? ' itemprop="description"' : '';
381
+
382
+ // here we trim the words for the premium version. The $fb_shortcode['words'] string actually comes from the javascript.
383
+ if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && array_key_exists( 'words', $fb_shortcode ) && 'top' !== $show_media || is_plugin_active( 'feed-them-social-combined-streams/feed-them-social-combined-streams.php' ) && array_key_exists( 'words', $fb_shortcode ) && ! empty( $fb_shortcode['words'] ) && 'top' !== $show_media || is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && array_key_exists( 'words', $fb_shortcode ) && 'top' !== $show_media ) {
384
+ $more = isset( $more ) ? $more : '';
385
+
386
+ $trimmed_content = $this->fts_custom_trim_words( $fb_message, $fb_shortcode['words'], $more );
387
+
388
+ // Going to consider this for the future if facebook fixes the api to define when are checking in. Add '.$checked_in.' inside the fts-jal-fb-message div.
389
+ // $checked_in = '<a target="_blank" class="fts-checked-in-img" href="https://www.facebook.com/'.$post_data->place->id.'"><img src="https://graph.facebook.com/'.$post_data->place->id.'/picture?width=150"/></a><a target="_blank" class="fts-checked-in-text-link" href="https://www.facebook.com/'.$post_data->place->id.'">'.esc_html("Checked in at", "feed-them-social").' '.$post_data->place->name.'</a><br/> '.esc_html("Location", "feed-them-social").': '.$post_data->place->location->city.', '.$post_data->place->location->country.' '.$post_data->place->location->zip.'<br/><a target="_blank" class="fts-fb-get-directions fts-checked-in-get-directions" href="https://www.facebook.com/'.$post_data->place->id.'">'.esc_html("Get Direction", "feed-them-social").'</a>';.
390
+ echo '<div class="fts-jal-fb-message"' . esc_attr( $itemprop_description_reviews ) . '>';
391
+
392
+ echo esc_html( $fb_title_job_opening );
393
+ // $trimmed_content CANNOT be esc at this time.
394
+ echo ! empty( $trimmed_content ) ? $trimmed_content : '';
395
+ // The Popup.
396
+ // echo $fb_shortcode['popup'] == 'yes' ? '<div class="fts-fb-caption"><a href="' . $fb_link . '" class="fts-view-on-facebook-link" target="_blank">' . esc_html__('View on Facebook', 'feed-them-social') . '</a></div> ' : '';.
397
+ echo '<div class="fts-clear"></div></div> ';
398
+
399
+ } elseif ( 'top' !== $show_media ) {
400
+ $fb_final_message = $this->fts_facebook_tag_filter( $fb_message );
401
+ echo '<div class="fts-jal-fb-message"' . esc_attr( $itemprop_description_reviews ) . '>';
402
+ // $fb_final_message CANNOT be esc at this time.
403
+ echo nl2br( $fb_final_message );
404
+ // If POPUP.
405
+ // echo isset($fb_shortcode['popup']) && $fb_shortcode['popup'] == 'yes' ? '<div class="fts-fb-caption"><a href="' . $fb_link . '" class="fts-view-on-facebook-link" target="_blank">' . esc_html('View on Facebook', 'feed-them-facebook') . '</a></div> ' : '';.
406
+ echo '<div class="fts-clear"></div></div>';
407
+ }
408
+ } elseif ( ! $fb_message && 'album_photos' === $fb_shortcode['type'] || ! $fb_message && 'albums' === $fb_shortcode['type'] ) {
409
+
410
+ echo '<div class="fts-jal-fb-description-wrap">';
411
+
412
+ $fb_caption ? $this->fts_facebook_post_cap( $fb_caption, $fb_shortcode, $fb_type ) : '';
413
+ // Output Photo Caption.
414
+ // if ( !is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && 'albums' === $fb_shortcode['type'] ){
415
+ // Album Post Description.
416
+ if ( 'albums' === $fb_shortcode['type'] ) {
417
+ echo '<div class="fts-fb-album-name-and-count ">';
418
+ }
419
+ $fb_name ? $this->fts_facebook_post_desc( $fb_name, $fb_shortcode, $fb_type, null, $fb_by ) : '';
420
+ // echo $fb_type;
421
+ // echo 'asdfasdf';
422
+ // Albums Photo Count.
423
+ echo $fb_album_photo_count ? esc_html( $fb_album_photo_count ) . ' Photos' : '';
424
+ if ( 'albums' === $fb_shortcode['type'] ) {
425
+ echo '</div>';
426
+ }
427
+ // }
428
+ // Location.
429
+ // $fb_location ? $this->fts_facebook_location( $fb_type, $fb_location ) : '';
430
+ // Output Photo Description.
431
+ $fb_description ? $this->fts_facebook_post_desc( $fb_description, $fb_shortcode, $fb_type, null, $fb_by ) : '';
432
+
433
+ // Output Photo Description.
434
+ if ( isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ) {
435
+ echo '<div class="fts-fb-caption fts-fb-album-view-link">';
436
+ // Album Covers.
437
+ if ( 'albums' === $fb_shortcode['type'] ) {
438
+
439
+ echo '<div class="fts-fb-album-additional-pics">';
440
+ // Album Covers. <img src="' . esc_url( $fb_album_additional_pic->images[1]->source ) . '"/>
441
+ $isFirst = true;
442
+ foreach ( $post_data->photos->data as $key => $fb_album_additional_pic ) {
443
+ // $fb_album_additional_pic_check = isset( $fb_album_additional_pic->name ) ? $this->fts_facebook_post_desc( $fb_album_additional_pic->name, $fb_shortcode, $fb_type, null, $fb_by ): '';
444
+ // $fb_album_additional_pic ? $fb_album_additional_pic_check : '';
445
+ echo '<div class="fts-fb-album-additional-pics-content">';
446
+
447
+ $hide_all_but_one_link = ! $isFirst ? 'style="display:none"' : '';
448
+
449
+ echo '<a href="' . esc_url( $fb_album_additional_pic->images[0]->source ) . '" class="fts-view-album-photos-large data-fb-album-photo-description" target="_blank" rel="noreferrer" ' . $hide_all_but_one_link . '>' . esc_html__( 'View Album', 'feed-them-social' ) . '</a>';
450
+ echo '<div class="fts-fb-album-additional-pics-description-wrap">';
451
+ echo '<div class="fts-jal-fb-description-wrap fts-fb-album-description-content fts-jal-fb-description-popup">';
452
+
453
+ // tied to date function.
454
+ $feed_type = 'facebook';
455
+ $album_created_time = isset( $fb_album_additional_pic->created_time ) ? $fb_album_additional_pic->created_time : '';
456
+ $times = $album_created_time;
457
+ $fts_final_date = $this->fts_custom_date( $times, $feed_type );
458
+ echo '<div class="fts-jal-fb-user-thumb">';
459
+ echo '<a href="https://www.facebook.com/' . esc_attr( $from_id_picture ) . '" target="_blank" rel="noreferrer"><img border="0" alt="' . esc_attr( $post_data->from->name ) . '" src="' . 'https://graph.facebook.com/' . esc_attr( $from_id_picture ) . '/picture"/></a>';
460
+ echo '</div>';
461
+
462
+ // UserName.
463
+ // $fts_facebook_reviews->reviews_rating_format CANNOT be esc at this time.
464
+ echo '<span class="fts-jal-fb-user-name"><a href="https://www.facebook.com/' . esc_attr( $from_id_picture ) . '" target="_blank" rel="noreferrer">' . esc_html( $post_data->from->name ) . '</a>' . esc_html( $fb_hide_shared_by_etc_text ) . '</span>';
465
+
466
+ echo '<div class="fts-fb-album-date-wrap">' . $fts_final_date . '</div>';
467
+
468
+ echo '<div class="fts-clear"></div>';
469
+
470
+ // Album Post Description.
471
+ // $fb_name ? $this->fts_facebook_post_desc( $fb_name, $fb_shortcode, $fb_type, null, $fb_by ) : '';
472
+ // Albums Photo Count.
473
+ $fb_name ? $this->fts_facebook_post_desc( $fb_name, $fb_shortcode, $fb_type, null, $fb_by ) : '';
474
+ $view_additional_album_photos = '24' == $key ? '. <a href="' . $fb_link . '" target="_blank" rel="noreferrer">' . esc_html__( 'View more for this Album', 'feed-them-social' ) . '</a>' : '';
475
+ echo $fb_album_photo_count ? ' ' . esc_html( $key + 1 ) . ' ' . esc_html__( 'of', 'feed-them-social' ) . ' ' . esc_html( $fb_album_photo_count ) . ' ' . esc_html__( 'Photos', 'feed-them-social' ) . ' ' . $view_additional_album_photos : '';
476
+ echo '<br/><br/>';
477
+
478
+ $fb_album_additional_pic_name = isset( $fb_album_additional_pic->name ) ? $fb_album_additional_pic->name : '';
479
+ $fb_album_additional_pic_name ? $this->fts_facebook_post_desc( $fb_album_additional_pic_name, $fb_shortcode, $fb_type, null, $fb_by ) : '';
480
+ echo '</div>';
481
+ echo '</div>';
482
+ echo '</div>';
483
+ $isFirst = false;
484
+ }
485
+
486
+ echo '</div>';
487
+ echo '</div>';
488
+ } elseif (
489
+
490
+ // Album Photos.
491
+ 'album_photos' === $fb_shortcode['type'] && ( isset( $fb_shortcode['video_album'] ) && 'yes' !== $fb_shortcode['video_album'] || ! isset( $fb_shortcode['video_album'] ) ) ) {
492
+ echo '<a href="' . esc_url( $fb_album_picture ) . '" class="fts-view-album-photos-large" target="_blank" rel="noreferrer">' . esc_html__( 'View Photo', 'feed-them-social' ) . '</a></div>';
493
+
494
+ } elseif (
495
+ // Video Albums.
496
+ isset( $fb_shortcode['video_album'] ) && 'yes' === $fb_shortcode['video_album'] ) {
497
+ if ( 'yes' !== $fb_shortcode['play_btn'] ) {
498
+
499
+ echo '<a href="' . esc_url( $embed_html ) . '" data-poster="' . esc_url( $video_photo ) . '" id="fts-view-vid1-' . esc_attr( $fts_dynamic_vid_name_string ) . '" class="fts-jal-fb-vid-html5video ' . esc_attr( $fts_view_fb_videos_btn ) . ' fts-view-fb-videos-large fts-view-fb-videos-btn fb-video-popup-' . esc_attr( $fts_dynamic_vid_name_string ) . '">' . esc_html__( 'View Video', 'feed-them-social' ) . '</a>';
500
+
501
+ echo '<div class="fts-fb-embed-iframe-check-used-for-popup fts-fb-embed-yes">';
502
+ if ( $embed_height >= $embed_width ) {
503
+ echo '<div class=' . esc_url( $data_height ) . ' data-width="' . esc_attr( $embed_width ) . '" data-height="' . esc_attr( $embed_height ) . '"></div>';
504
+ }
505
+ echo '</div>';
506
+ }
507
+ echo '</div>';
508
+ } else {
509
+ // photos.
510
+ echo '<a href="' . esc_url( $post_data->source ) . '" class="fts-view-album-photos-large" target="_blank" rel="noreferrer">' . esc_html__( 'View Photo', 'feed-them-social' ) . '</a></div>';
511
+ }
512
+
513
+ // echo '<div class="fts-fb-caption"><a class="view-on-facebook-albums-link" href="' . $fb_link . '" target="_blank">' . esc_html('View on Facebook', 'feed-them-social') . '</a></div>';.
514
+ }
515
+
516
+ echo '<div class="fts-clear"></div></div>';
517
+ } //END Output Message
518
+ // elseif ($fb_message == '' && $fb_shortcode['type'] !== 'album_photos' || $fb_message == '' && $fb_shortcode['type'] !== 'albums') {.
519
+ // If POPUP.
520
+ // echo $fb_shortcode['popup'] == 'yes' ? '<div class="fts-jal-fb-message"><div class="fts-fb-caption"><a href="' . $fb_link . '" class="fts-view-on-facebook-link" target="_blank">' . esc_html('View on Facebook', 'feed-them-facebook') . '</a></div></div>' : '';.
521
+ // }.
522
+ if ( 'top' !== $show_media ) {
523
+ echo '</div>';
524
+ // end .fts-jal-fb-top-wrap <!--end fts-jal-fb-top-wrap -->.
525
+ }
526
+ }
527
+ // Post Type Build.
528
+ $fts_show_post = false;
529
+
530
+ switch ( $fb_type ) {
531
+
532
+ // START NOTE POST.
533
+ case 'knowledge_note':
534
+ // && !$fb_picture == '' makes it so the attachment unavailable message does not show up.
535
+ // if (!$fb_picture && !$fb_name && !$fb_description && !$fb_picture == '') {.
536
+ echo '<div class="fts-jal-fb-link-wrap">';
537
+ // Output Link Picture.
538
+ $fb_picture ? $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, $post_data->attachments->data[0]->media->image->src ) : '';
539
+
540
+ if ( $fb_name || $fb_caption || $fb_description ) {
541
+ echo '<div class="fts-jal-fb-description-wrap">';
542
+ // Output Link Name.
543
+ $fb_name ? $this->fts_facebook_post_name( $fb_link, $fb_name, $fb_type ) : '';
544
+ // Output Link Caption.
545
+ if ( 'Attachment Unavailable. This attachment may have been removed or the person who shared it may not have permission to share it with you.' === $fb_caption ) {
546
+ echo '<div class="fts-jal-fb-caption" style="width:100% !important">';
547
+ esc_html( 'This user\'s permissions are keeping you from seeing this post. Please Click "View on Facebook" to view this post on this group\'s facebook wall.', 'feed-them-social' );
548
+ echo '</div>';
549
+ } else {
550
+ $this->fts_facebook_post_cap( $fb_caption, $fb_shortcode, $fb_type );
551
+ }
552
+ // If POPUP.
553
+ // echo $fb_shortcode['popup'] == 'yes' ? '<div class="fts-fb-caption"><a href="' . $fb_link . '" class="fts-view-on-facebook-link" target="_blank">' . esc_html('View on Facebook', 'feed-them-facebook') . '</a></div> ' : '';.
554
+ // Output Link Description.
555
+ // echo $fb_description ? $this->fts_facebook_post_desc($fb_description, $fb_shortcode, $fb_type) : '';.
556
+ echo '<div class="fts-clear"></div></div>';
557
+ }
558
+ echo '<div class="fts-clear"></div></div>';
559
+ // }.
560
+ break;
561
+
562
+ // START STATUS POST.
563
+ case 'status':
564
+ // && !$fb_picture == '' makes it so the attachment unavailable message does not show up.
565
+ // if (!$fb_picture && !$fb_name && !$fb_description && !$fb_picture == '') {.
566
+ echo '<div class="fts-jal-fb-link-wrap">';
567
+ // Output Link Picture.
568
+ if ( $fb_picture_job ) {
569
+ $this->fts_facebook_post_photo( $fb_joblink, $fb_shortcode, $post_data->from->name, $fb_picture_job );
570
+ } else {
571
+ $fb_picture ? $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, $post_data->picture ) : '';
572
+ }
573
+
574
+ if ( $fb_name || $fb_caption || $fb_description ) {
575
+ echo '<div class="fts-jal-fb-description-wrap">';
576
+ // Output Link Name.
577
+ $fb_name ? $this->fts_facebook_post_name( $fb_link, $fb_name, $fb_type ) : '';
578
+ // Output Link Caption.
579
+ if ( 'Attachment Unavailable. This attachment may have been removed or the person who shared it may not have permission to share it with you.' === $fb_caption ) {
580
+ echo '<div class="fts-jal-fb-caption" style="width:100% !important">';
581
+ echo esc_html( 'This user\'s permissions are keeping you from seeing this post. Please Click "View on Facebook" to view this post on this group\'s facebook wall.', 'feed-them-social' );
582
+ echo '</div>';
583
+ } else {
584
+ $this->fts_facebook_post_cap( $fb_caption, $fb_shortcode, $fb_type );
585
+ }
586
+ // Output Link Description.
587
+ $fb_description ? $this->fts_facebook_post_desc( $fb_description, $fb_shortcode, $fb_type ) : '';
588
+ echo '<div class="fts-clear"></div></div>';
589
+ }
590
+ echo '<div class="fts-clear"></div></div>';
591
+ // }
592
+ break;
593
+ // Start Multiple Events.
594
+ case 'events':
595
+ $single_event_id = $post_data->id;
596
+ $single_event_info = json_decode( $single_event_array_response[ 'event_single_' . $single_event_id . '_info' ] );
597
+ $single_event_location = json_decode( $single_event_array_response[ 'event_single_' . $single_event_id . '_location' ] );
598
+ $single_event_cover_photo = json_decode( $single_event_array_response[ 'event_single_' . $single_event_id . '_cover_photo' ] );
599
+ $single_event_ticket_info = json_decode( $single_event_array_response[ 'event_single_' . $single_event_id . '_ticket_info' ] );
600
+ // echo'<pre>';.
601
+ // print_r($single_event_info);.
602
+ // echo'</pre>';.
603
+ // Event Cover Photo.
604
+ $event_cover_photo = isset( $single_event_cover_photo->cover->source ) ? $single_event_cover_photo->cover->source : '';
605
+ $event_description = isset( $single_event_info->description ) ? $single_event_info->description : '';
606
+ echo '<div class="fts-jal-fb-right-wrap fts-events-list-wrap">';
607
+ // Link Picture.
608
+ $fb_event_name = isset( $single_event_info->name ) ? $single_event_info->name : '';
609
+ $fb_event_location = isset( $single_event_location->place->name ) ? $single_event_location->place->name : '';
610
+ $fb_event_city = isset( $single_event_location->place->location->city ) ? $single_event_location->place->location->city . ', ' : '';
611
+ $fb_event_state = isset( $single_event_location->place->location->state ) ? $single_event_location->place->location->state : '';
612
+ $fb_event_street = isset( $single_event_location->place->location->street ) ? $single_event_location->place->location->street : '';
613
+ $fb_event_zip = isset( $single_event_location->place->location->zip ) ? ' ' . $single_event_location->place->location->zip : '';
614
+ $fb_event_latitude = isset( $single_event_location->place->location->latitude ) ? $single_event_location->place->location->latitude : '';
615
+ $fb_event_longitude = isset( $single_event_location->place->location->longitude ) ? $single_event_location->place->location->longitude : '';
616
+ $fb_event_ticket_info = isset( $single_event_ticket_info->ticket_uri ) ? $single_event_ticket_info->ticket_uri : '';
617
+ date_default_timezone_set( get_option( 'fts-timezone' ) );
618
+
619
+ // custom one day ago check.
620
+ if ( 'one-day-ago' === $custom_date_check ) {
621
+ $fb_event_start_time = date_i18n( 'l, F jS, Y \a\t g:ia', strtotime( $single_event_info->start_time ) );
622
+ } else {
623
+ $fb_event_start_time = date_i18n( $custom_date_format, strtotime( $single_event_info->start_time ) );
624
+ }
625
+
626
+ // Output Photo Description.
627
+ if ( ! empty( $event_cover_photo ) ) {
628
+ echo isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] && is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) ? '<a href="' . esc_url( $event_cover_photo ) . '" class="fts-jal-fb-picture fts-fb-large-photo" target="_blank" rel="noreferrer"><img class="fts-fb-event-photo" src="' . esc_url( $event_cover_photo ) . '"></a>' : '<a href="https://www.facebook.com/events/' . esc_attr( $single_event_id ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-picture fts-fb-large-photo"><img class="fts-fb-event-photo" src="' . esc_url( $event_cover_photo ) . '" /></a>';
629
+ }
630
+ echo '<div class="fts-jal-fb-top-wrap">';
631
+ echo '<div class="fts-jal-fb-message">';
632
+ // Link Name.
633
+ echo '<div class="fts-event-title-wrap">';
634
+ $fb_event_name ? $this->fts_facebook_post_name( 'https://www.facebook.com/events/' . esc_attr( $single_event_id ) . '', esc_attr( $fb_event_name ), esc_attr( $fb_type ) ) : '';
635
+ echo '</div>';
636
+ // Link Caption.
637
+ if ( $fb_event_start_time ) {
638
+ echo '<div class="fts-fb-event-time">' . $fb_event_start_time . '</div>';
639
+ }
640
+ // Link Description.
641
+ if ( ! empty( $fb_event_location ) ) {
642
+ echo '<div class="fts-fb-location"><span class="fts-fb-location-title">' . esc_html( $fb_event_location ) . '</span>';
643
+ // Street Adress.
644
+ echo esc_html( $fb_event_street );
645
+ // City & State.
646
+ echo $fb_event_city || $fb_event_state ? '<br/>' . esc_html( $fb_event_city . $fb_event_state . $fb_event_zip ) : '';
647
+ echo '</div>';
648
+ }
649
+ // Get Directions.
650
+ if ( ! empty( $fb_event_latitude ) && ! empty( $fb_event_longitude ) ) {
651
+ echo '<a target="_blank" class="fts-fb-get-directions" href="' . esc_html( 'https://www.google.com/maps/dir/Current+Location/' . $fb_event_latitude . ',' . $fb_event_longitude . '' ) . '"
652
  >' . esc_html( 'Get Directions', 'feed-them-social' ) . '</a>';
653
+ }
654
+ if ( ! empty( $fb_event_ticket_info ) && ! empty( $fb_event_ticket_info ) ) {
655
+ echo '<a target="_blank" rel="noreferrer" class="fts-fb-ticket-info" href="' . esc_url( $single_event_ticket_info->ticket_uri ) . '">' . esc_html( 'Ticket Info', 'feed-them-social' ) . '</a>';
656
+ }
657
+ // Output Message.
658
+ if ( ! empty( $fb_shortcode['words'] ) && $event_description && is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) ) {
659
+ // here we trim the words for the premium version. The $fb_shortcode['words'] string actually comes from the javascript.
660
+ $this->fts_facebook_post_desc( $event_description, $fb_shortcode, $fb_type, null, $fb_by, $fb_shortcode['type'] );
661
+ } else {
662
+ // if the premium plugin is not active we will just show the regular full description.
663
+ $this->fts_facebook_post_desc( $event_description, $fb_type, null, $fb_by, $fb_shortcode['type'] );
664
+ }
665
+ // Our POPUP.
666
+ // echo $fb_shortcode['popup'] == 'yes' ? '<div class="fts-fb-caption"><a href="https://www.facebook.com/events/' . $single_event_id . '" class="fts-view-on-facebook-link" target="_blank">' . esc_html('View Event on Facebook', 'feed-them-facebook') . '</a></div> ' : '';.
667
+ echo '<div class="fts-clear"></div></div></div>';
668
+ break;
669
+
670
+ // START LINK POST.
671
+ case 'share':
672
+ echo '<div class="fts-jal-fb-link-wrap">';
673
+ // start url check.
674
+ if ( ! empty( $fb_link ) ) {
675
+ $url = $fb_link;
676
+ $url_parts = parse_url( $url );
677
+ $host = $url_parts['host'];
678
+ }
679
+
680
+ if ( isset( $host ) && 'www.facebook.com' === $host ) {
681
+ $spliturl = $url_parts['path'];
682
+ $path_components = explode( '/', $spliturl );
683
+ $first_dir = $path_components[1];
684
+ }
685
+ // end url check.
686
+ // Output Link Picture.
687
+ // echo isset($fb_shortcode['popup']) && $fb_shortcode['popup'] == 'yes' ? '<div class="fts-fb-caption"><a href="' . $fb_link . '" class="fts-view-on-facebook-link" target="_blank">' . esc_html('View on Facebook', 'feed-them-social') . '</a></div> ' : '';.
688
+ if ( isset( $host ) && 'www.facebook.com' === $host && 'events' === $first_dir ) {
689
+ $fb_picture ? $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, $post_data->picture ) : '';
690
+ } elseif ( strpos( $fb_link, 'soundcloud' ) > 0 ) {
691
+ // Get the SoundCloud URL.
692
+ $url = $fb_link;
693
+ // Get the JSON data of song details with embed code from SoundCloud oEmbed.
694
+ $get_values = file_get_contents( 'http://soundcloud.com/oembed?format=js&url=' . $url . '&auto_play=true&iframe=true' );
695
+ // Clean the Json to decode.
696
+ $decode_iframe = substr( $get_values, 1, -2 );
697
+ // json decode to convert it as an array.
698
+ $json_obj = json_decode( $decode_iframe );
699
+ // Change the height of the embed player if you want else uncomment below line.
700
+ // echo str_replace('height="400"', 'height="140"', $json_obj->html);.
701
+ $fts_dynamic_vid_name_string = sanitize_key( $this->fts_rand_string( 10 ) . '_' . $fb_shortcode['type'] );
702
+ $fts_dynamic_vid_name = 'feed_dynamic_video_class' . $fts_dynamic_vid_name_string;
703
+ echo '<div class="fts-jal-fb-vid-picture ' . esc_attr( $fts_dynamic_vid_name ) . '">';
704
+ if ( ! empty( $post_data->attachments->data[0]->media->image->src ) ) {
705
+ $fb_picture ? $this->fts_facebook_post_photo( 'javascript:;', $fb_shortcode, $post_data->from->name, $post_data->attachments->data[0]->media->image->src ) : '';
706
+ } elseif ( ! empty( $post_data->picture ) ) {
707
+ $fb_picture ? $this->fts_facebook_post_photo( 'javascript:;', $fb_shortcode, $post_data->from->name, $post_data->picture ) : '';
708
+ }
709
+ echo '<div class="fts-jal-fb-vid-play-btn"></div>';
710
+ echo '</div>';
711
+ echo '<script>';
712
+ echo 'jQuery(document).ready(function() {';
713
+ echo 'jQuery(".' . esc_js( $fts_dynamic_vid_name ) . '").click(function() {';
714
+ echo 'jQuery(this).addClass("fts-vid-div");';
715
+ echo 'jQuery(this).removeClass("fts-jal-fb-vid-picture");';
716
+ echo ' jQuery(this).prepend(\'<div class="fts-fluid-videoWrapper">' . $json_obj->html . '</div>\');';
717
+ if ( isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] ) {
718
+ echo 'jQuery(".fts-slicker-facebook-posts").masonry( "reloadItems");';
719
+ echo 'jQuery(".fts-slicker-facebook-posts").masonry( "layout" );';
720
+ }
721
+ echo '});';
722
+ echo '});';
723
+ echo '</script>';
724
+ } elseif ( ! empty( $post_data->attachments->data[0]->media->image->src ) ) {
725
+ $fb_picture ? $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, $post_data->attachments->data[0]->media->image->src ) : '';
726
+ } elseif ( ! empty( $post_data->picture ) ) {
727
+ $fb_picture ? $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, $post_data->picture ) : '';
728
+ }
729
+
730
+ $fb_shortcode['words'] = isset( $fb_shortcode['words'] ) ? $fb_shortcode['words'] : '';
731
+ // Description Wrap.
732
+ echo '<div class="fts-jal-fb-description-wrap">';
733
+ // Output Link Name.
734
+ $fb_name ? $this->fts_facebook_post_name( $fb_link, $fb_name, $fb_type ) : '';
735
+ if ( isset( $host ) && 'www.facebook.com' === $host && 'events' === $first_dir ) {
736
+ echo ' &#9658; ';
737
+ echo '<a href="' . esc_url( $fb_link ) . '" class="fts-jal-fb-name" target="_blank" rel="noreferrer">' . esc_html( $fb_link_event_name ) . '</a>';
738
+ }//end if event.
739
+ // Output Link Description.
740
+ $fb_description ? $this->fts_facebook_post_desc( $fb_description, $fb_shortcode, $fb_type ) : '';
741
+
742
+ // Output Link Caption.
743
+ $fb_caption ? $this->fts_facebook_post_cap( $fb_caption, $fb_shortcode, $fb_type ) : '';
744
+ echo '<div class="fts-clear"></div></div>';
745
+ echo '<div class="fts-clear"></div></div>';
746
+ break;
747
+
748
+ // START VIDEO POST.
749
+ case 'video_direct_response' :
750
+ case 'video_inline' :
751
+ // $video_data = json_decode($response_post_array[$post_data_key . '_video']);.
752
+ // echo '<pre>';.
753
+ // print_r($video_data);.
754
+ // echo '</pre>';.
755
+ echo '<div class="fts-jal-fb-vid-wrap">';
756
+
757
+ if ( ! empty( $fb_picture ) ) {
758
+
759
+ // Create Dynamic Class Name.
760
+ $fts_dynamic_vid_name_string = sanitize_key( $this->fts_rand_string( 10 ) . '_' . $fb_shortcode['type'] );
761
+ $fts_dynamic_vid_name = 'feed_dynamic_video_class' . $fts_dynamic_vid_name_string;
762
+ echo '<div class="fts-jal-fb-vid-picture ' . esc_html( $fts_dynamic_vid_name ) . '">';
763
+
764
+ if ( strpos( $fb_link, 'youtube' ) > 0 || strpos( $fb_link, 'youtu.be' ) > 0 ) {
765
+ preg_match( "/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:m\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&\"'>]+)/", $fb_video_embed, $matches );
766
+ $video_url_final = 'https://www.youtube.com/watch?v=' . $matches[1];
767
+ } else {
768
+ $video_url_final = esc_url( $embed_html );
769
+ }
770
+
771
+ // This puts the video in a popup instead of displaying it directly on the page.
772
+ if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ) {
773
+
774
+ if ( strpos( $fb_link, 'youtube' ) > 0 || strpos( $fb_link, 'youtu.be' ) > 0 || strpos( $fb_link, 'vimeo' ) > 0 ) {
775
+ echo '<a href="' . esc_url( $video_url_final ) . '" class="fts-facebook-link-target fts-jal-fb-vid-image fts-iframe-type">';
776
+ } else {
777
+
778
+ if ( 'video_direct_response' === $post_data->attachments->data[0]->type || 'video_inline' === $post_data->attachments->data[0]->type ) {
779
+ $page_id = $post_data->from->id;
780
+ $video_id = $post_data->attachments->data[0]->target->id;
781
+ $fb_embed_url = 'https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2F' . $page_id . '%2Fvideos%2F' . $video_id . '%2F&autoplay=true';
782
+ echo '<a href="' . esc_url( $fb_embed_url ) . '" class="fts-jal-fb-vid-image ' . esc_attr( $fts_view_fb_videos_btn ) . ' fts-jal-fb-vid-html5video ">';
783
+
784
+ } else {
785
+ echo '<a href="' . esc_url( $embed_html ) . '" class="fts-facebook-link-target fts-jal-fb-vid-html5video ">';
786
+ }
787
+ }
788
+ }
789
+ // srl: 8/27/17 - FB BUG: for some reason the full_picture for animated gifs is not correct so we dig deeper and grab another image size fb has set.
790
+ if ( isset( $post_data->attachments->data[0]->type ) && 'animated_image_video' === $post_data->attachments->data[0]->type ) {
791
+ $vid_pic = $post_data->attachments->data[0]->media->image->src;
792
+ } else {
793
+ $vid_pic = $post_data->attachments->data[0]->media->image->src;
794
+ }
795
+ echo '<img class="fts-jal-fb-vid-image" border="0" alt="' . esc_attr( $post_data->from->name ) . '" src="' . esc_url( $vid_pic ) . '"/>';
796
+
797
+ // This puts the video in a popup instead of displaying it directly on the page.
798
+ if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ) {
799
+ echo '</a>';
800
+ }
801
+
802
+ echo '<div class="fts-jal-fb-vid-play-btn"></div></div>';
803
+
804
+ // If this is a facebook embed video then ouput Iframe and script.
805
+ $embed_height = isset( $post_data->attachments->data[0]->media->image->height ) ? $post_data->attachments->data[0]->media->image->height : '';
806
+ $embed_width = isset( $post_data->attachments->data[0]->media->image->width ) ? $post_data->attachments->data[0]->media->image->width : '';
807
+ $video_type = isset( $post_data->attachments->data[0]->type ) ? $post_data->attachments->data[0]->type : '';
808
+ // $video_inline = isset( $post_data->attachments->data[0]->type ) ? $post_data->attachments->data[0]->type : '';
809
+
810
+ // && $video_inline == 'video_inline'. /////// || 'video' === $video_type && 'animated_image_video' === $video_inline
811
+ if ( 'video_direct_response' === $video_type || 'video_inline' === $video_type ) {
812
+
813
+ if ( $embed_height > $embed_width ) {
814
+ $data_height = 'fts-greater-than-width-height';
815
+ } elseif ( $embed_height === $embed_width ) {
816
+ $data_height = 'fts-equal-width-height fts-fluid-videoWrapper ';
817
+ } else {
818
+ $data_height = 'fts-fluid-videoWrapper';
819
+ }
820
+
821
+ echo '<div class="fts-fb-embed-iframe-check-used-for-popup fts-fb-embed-yes">';
822
+ if ( $embed_height >= $embed_width ) {
823
+ echo '<div class=' . esc_attr( $data_height ) . ' data-width="' . esc_attr( $embed_width ) . '" data-height="' . esc_attr( $embed_height ) . '"></div>';
824
+ }
825
+ echo '</div>';
826
+ // This puts the video on the page instead of the popup if you don't have the premium version.
827
+ if ( ! isset( $fb_shortcode['popup'] ) || isset( $fb_shortcode['popup'] ) && 'yes' !== $fb_shortcode['popup'] && is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) || isset( $fb_shortcode['popup'] ) && empty( $fb_shortcode['popup'] ) || isset( $fb_shortcode['popup'] ) && 'no' === $fb_shortcode['popup'] ) {
828
+
829
+ $page_id = isset( $post_data->from->id ) ? $post_data->from->id : '';
830
+ $video_id = isset( $post_data->attachments->data[0]->target->id ) ? $post_data->attachments->data[0]->target->id : '';
831
+
832
+ $fb_embed_url = 'https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2F' . $page_id . '%2Fvideos%2F' . $video_id . '%2F&autoplay=true';
833
+
834
+ echo '<script>';
835
+ echo 'jQuery(document).ready(function() {';
836
+ echo 'jQuery(".' . esc_js( $fts_dynamic_vid_name ) . '").click(function() {';
837
+ echo 'jQuery(this).addClass("fts-vid-div");';
838
+ echo 'jQuery(this).removeClass("fts-jal-fb-vid-picture");';
839
+ // echo 'jQuery(this).prepend(\'<div class="fts-fluid-videoWrapper"><iframe height="281" class="video'.$fb_post_id.'" src="http://www.youtube.com/embed/'.$youtubeURLfinal.'?autoplay=1" frameborder="0" allowfullscreen></iframe></div>\');';.
840
+ echo 'jQuery(this).prepend(\'<div class="' . esc_js( $data_height ) . ' fts-fb-video-on-page" ><iframe style="background:none !important" class="video-' . esc_js( $fb_post_id ) . '" src="' . esc_url( $fb_embed_url ) . '" frameborder="0" allowfullscreen></iframe></div>\');';
841
+ echo 'jQuery( ".' . esc_js( $fts_dynamic_vid_name ) . ' .fts-greater-than-width-height.fts-fb-video-on-page, .' . esc_js( $fts_dynamic_vid_name ) . ' iframe" ).css({"height": "' . esc_js( $embed_height ) . 'px", "width": "' . esc_js( $embed_width ) . 'px"});';
842
+ if ( isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] || isset( $fb_shortcode['grid_combined'] ) && 'yes' === $fb_shortcode['grid_combined'] ) {
843
+ echo 'jQuery(".fts-slicker-facebook-posts, .fts-mashup").masonry( "reloadItems");';
844
+ echo 'jQuery(".fts-slicker-facebook-posts, .fts-mashup").masonry( "layout" );';
845
+ }
846
+ echo '});';
847
+ echo '});';
848
+ echo '</script>';
849
+ }
850
+ }
851
+ // strip Youtube URL then ouput Iframe and script.
852
+ if ( strpos( $fb_link, 'youtube' ) > 0 ) {
853
+ // $pattern = '#^(?:https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com(?:/embed/|/v/|/watch\?v=|/watch\?.+&v=))([\w-]{11})(?:.+)?$#x';.
854
+ // preg_match($pattern, $fb_link, $matches);.
855
+ // $youtubeURLfinal = $matches[1];.
856
+ // This puts the video on the page instead of the popup if you don't have the premium version.
857
+ if ( ! isset( $fb_shortcode['popup'] ) || isset( $fb_shortcode['popup'] ) && 'yes' !== $fb_shortcode['popup'] && is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) || isset( $fb_shortcode['popup'] ) && empty( $fb_shortcode['popup'] ) || isset( $fb_shortcode['popup'] ) && 'no' === $fb_shortcode['popup'] ) {
858
+ echo '<script>jQuery(document).ready(function() {';
859
+ echo 'jQuery(".' . esc_js( $fts_dynamic_vid_name ) . '").click(function() {';
860
+ echo 'jQuery(this).addClass("fts-vid-div");';
861
+ echo 'jQuery(this).removeClass("fts-jal-fb-vid-picture");';
862
+ // echo 'jQuery(this).prepend(\'<div class="fts-fluid-videoWrapper"><iframe height="281" class="video'.$fb_post_id.'" src="https://www.youtube.com/embed/'.$youtubeURLfinal.'?autoplay=1" frameborder="0" allowfullscreen></iframe></div>\');';.
863
+ echo 'jQuery(this).prepend(\'<div class="fts-fluid-videoWrapper"><iframe height="281" class="video' . esc_js( $fb_post_id ) . '" src="' . esc_url( $fb_video_embed ) . '" frameborder="0" allowfullscreen></iframe></div>\');';
864
+ if ( isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] || isset( $fb_shortcode['grid_combined'] ) && 'yes' === $fb_shortcode['grid_combined'] ) {
865
+ echo 'jQuery(".fts-slicker-facebook-posts, .fts-mashup").masonry( "reloadItems");';
866
+ echo 'jQuery(".fts-slicker-facebook-posts, .fts-mashup").masonry( "layout" );';
867
+ }
868
+ echo '});';
869
+ echo '});</script>';
870
+ }
871
+ } elseif (
872
+ // strip Youtube URL then ouput Iframe and script.
873
+ strpos( $fb_link, 'youtu.be' ) > 0 ) {
874
+ // $pattern = '#^(?:https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com(?:/embed/|/v/|/watch\?v=|/watch\?.+&v=))([\w-]{11})(?:.+)?$#x';.
875
+ // preg_match($pattern, $fb_link, $matches);.
876
+ // $youtubeURLfinal = $matches[1];.
877
+ // This puts the video in a popup instead of displaying it directly on the page.
878
+ if ( ! isset( $fb_shortcode['popup'] ) || isset( $fb_shortcode['popup'] ) && 'yes' !== $fb_shortcode['popup'] && is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) || isset( $fb_shortcode['popup'] ) && empty( $fb_shortcode['popup'] ) || isset( $fb_shortcode['popup'] ) && 'no' === $fb_shortcode['popup'] ) {
879
+ echo '<script>';
880
+ echo 'jQuery(document).ready(function() {';
881
+ echo 'jQuery(".' . esc_js( $fts_dynamic_vid_name ) . '").click(function() {';
882
+ echo 'jQuery(this).addClass("fts-vid-div");';
883
+ echo 'jQuery(this).removeClass("fts-jal-fb-vid-picture");';
884
+ // echo 'jQuery(this).prepend(\'<div class="fts-fluid-videoWrapper"><iframe height="281" class="video'.$fb_post_id.'" src="http://www.youtube.com/embed/'.$youtubeURLfinal.'?autoplay=1" frameborder="0" allowfullscreen></iframe></div>\');';.
885
+ echo 'jQuery(this).prepend(\'<div class="fts-fluid-videoWrapper"><iframe height="281" class="video' . esc_js( $fb_post_id ) . '" src="' . esc_url( $fb_video_embed ) . '" frameborder="0" allowfullscreen></iframe></div>\');';
886
+ if ( isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] || isset( $fb_shortcode['grid_combined'] ) && 'yes' === $fb_shortcode['grid_combined'] ) {
887
+ echo 'jQuery(".fts-slicker-facebook-posts, .fts-mashup").masonry( "reloadItems");';
888
+ echo 'jQuery(".fts-slicker-facebook-posts, .fts-mashup").masonry( "layout" );';
889
+ }
890
+ echo '});';
891
+ echo '});';
892
+ echo '</script>';
893
+ }
894
+ } elseif (
895
+ // strip Vimeo URL then ouput Iframe and script.
896
+ strpos( $fb_link, 'vimeo' ) > 0 ) {
897
+ // $pattern = '/(\d+)/';.
898
+ // preg_match($pattern, $fb_link, $matches);.
899
+ // $vimeoURLfinal = $matches[0];.
900
+ // This puts the video in a popup instead of displaying it directly on the page.
901
+ if ( ! isset( $fb_shortcode['popup'] ) || isset( $fb_shortcode['popup'] ) && 'yes' !== $fb_shortcode['popup'] && is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) || isset( $fb_shortcode['popup'] ) && empty( $fb_shortcode['popup'] ) || isset( $fb_shortcode['popup'] ) && 'no' === $fb_shortcode['popup'] ) {
902
+ echo '<script>';
903
+ echo 'jQuery(document).ready(function() {';
904
+ echo 'jQuery(".' . esc_js( $fts_dynamic_vid_name ) . '").click(function() {';
905
+ echo 'jQuery(this).addClass("fts-vid-div");';
906
+ echo 'jQuery(this).removeClass("fts-jal-fb-vid-picture");';
907
+ // echo 'jQuery(this).prepend(\'<div class="fts-fluid-videoWrapper"><iframe src="http://player.vimeo.com/video/'.$vimeoURLfinal.'?autoplay=1" class="video'.$fb_post_id.'" height="390" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>\');';.
908
+ echo 'jQuery(this).prepend(\'<div class="fts-fluid-videoWrapper"><iframe src="' . esc_url( $fb_video_embed ) . '" class="video' . esc_js( $fb_post_id ) . '" height="390" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>\');';
909
+ if ( isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] || isset( $fb_shortcode['grid_combined'] ) && 'yes' === $fb_shortcode['grid_combined'] ) {
910
+ echo 'jQuery(".fts-slicker-facebook-posts, .fts-mashup").masonry( "reloadItems");';
911
+ echo 'jQuery(".fts-slicker-facebook-posts, .fts-mashup").masonry( "layout" );';
912
+ }
913
+ echo '});';
914
+ echo '});';
915
+ echo '</script>';
916
+ }
917
+ }
918
+ }
919
+ if ( $fb_name || $fb_caption || $fb_description ) {
920
+ echo '<div class="fts-jal-fb-description-wrap fb-id' . esc_attr( $fb_post_id ) . '">';
921
+ // Output Video Name.
922
+ $fb_name ? $this->fts_facebook_post_name( $fb_link, $fb_name, $fb_type, $fb_post_id ) : '';
923
+ // Output Video Description.
924
+ $fb_description ? $this->fts_facebook_post_desc( $fb_description, $fb_shortcode, $fb_type, $fb_post_id ) : '';
925
+ // Output Video Caption.
926
+ $fb_caption ? $this->fts_facebook_post_cap( $fb_caption, $fb_shortcode, $fb_type, $fb_post_id ) : '';
927
+ echo '<div class="fts-clear"></div></div>';
928
+ }
929
+ echo '<div class="fts-clear"></div></div>';
930
+ break;
931
+ // START PHOTO POST.
932
+ case 'photo':
933
+ if ( isset( $fts_hide_photos_type ) && 'yes' === $fts_hide_photos_type && 'album_photos' !== $fb_shortcode['type'] && 'yes' !== $fb_shortcode['video_album'] ) {
934
+ break;
935
+ }
936
+
937
+ // Wrapping with if statement to prevent Notice on some facebook page feeds.
938
+ if ( 'group' === $fb_shortcode['type'] ) {
939
+ $photo_source = json_decode( $response_post_array[ $post_data_key . '_group_post_photo' ] );
940
+ }
941
+
942
+ echo '<div class="fts-jal-fb-link-wrap fts-album-photos-wrap"';
943
+ if ( 'album_photos' === $fb_shortcode['type'] || 'albums' === $fb_shortcode['type'] ) {
944
+ echo ' style="line-height:' . esc_attr( $fb_shortcode['image_height'] ) . ' !important;"';
945
+ }
946
+ echo '>';
947
+ // echo isset($fb_shortcode['popup']) && $fb_shortcode['popup'] == 'yes' ? '<div class="fts-fb-caption"><a href="' . $fb_link . '" class="fts-view-on-facebook-link" target="_blank">' . esc_html('View on Facebook', 'feed-them-social') . '</a></div> ' : '';.
948
+ // Output Photo Picture.
949
+ if ( $fb_picture ) {
950
+ if ( $fb_post_object_id ) {
951
+ $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, 'https://graph.facebook.com/' . $fb_post_object_id . '/picture' );
952
+ } else {
953
+ if ( isset( $fb_shortcode['video_album'] ) && 'yes' === $fb_shortcode['video_album'] ){
954
+ echo $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, $video_photo );
955
+ }
956
+ elseif ( isset( $fb_shortcode['type'] ) && 'album_photos' === $fb_shortcode['type'] ) {
957
+ echo $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, $post_data->source );
958
+ }
959
+ else {
960
+ echo $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, $post_data->attachments->data[0]->media->image->src );
961
+ }
962
+ }
963
+ }
964
+ echo '<div class="slicker-facebook-album-photoshadow"></div>';
965
+ // FB Video play button for facebook videos. This button takes data from our a tag and along with additional js in the magnific-popup.js we can now load html5 videos. SO lightweight this way because no pre-loading of videos are on the page. We only show the posterboard on mobile devices because tablets and desktops will auto load the videos. SRL.
966
+ if ( isset( $fb_shortcode['video_album'] ) && 'yes' === $fb_shortcode['video_album'] ) {
967
+ if ( isset( $fb_shortcode['play_btn'] ) && 'yes' === $fb_shortcode['play_btn'] ) {
968
+ $fb_play_btn_visible = isset( $fb_shortcode['play_btn_visible'] ) && 'yes' === $fb_shortcode['play_btn_visible'] ? ' visible-video-button' : '';
969
+
970
+ // $post_data_source = isset($post_data->source) ? $post_data->source : $embed_html;.
971
+ // $post_data_source = isset($embed_html) ? $embed_html : '';.
972
+ // $post_data_format_3_picture = isset($post_data->format[3]->picture) ? $post_data->format[3]->picture : '';.
973
+ echo '<a href="' . esc_url( $embed_html ) . '" data-poster="" id="fts-view-vid1-' . esc_attr( $fts_dynamic_vid_name_string ) . '" title="' . esc_html( $fb_description ) . '" class="fts-jal-fb-vid-html5video ' . esc_attr( $fts_view_fb_videos_btn . ' fb-video-popup-' . $fts_dynamic_vid_name_string . ' ' . $fb_play_btn_visible ) . ' fts-slicker-backg" style="height:' . esc_attr( $fb_shortcode['play_btn_size'] ) . ' !important; width:' . esc_attr( $fb_shortcode['play_btn_size'] ) . '; line-height: ' . esc_attr( $fb_shortcode['play_btn_size'] ) . '; font-size:' . esc_attr( $fb_shortcode['play_btn_size'] ) . '"><span class="fts-fb-video-icon" style="height:' . esc_attr( $fb_shortcode['play_btn_size'] ) . '; width:' . esc_attr( $fb_shortcode['play_btn_size'] ) . '; line-height:' . esc_attr( $fb_shortcode['play_btn_size'] ) . '; font-size:' . esc_attr( $fb_shortcode['play_btn_size'] ) . '"></span></a>';
974
+
975
+ echo '<div class="fts-fb-embed-iframe-check-used-for-popup fts-fb-embed-yes">';
976
+ if ( $embed_height >= $embed_width ) {
977
+ echo '<div class=' . esc_attr( $data_height ) . ' data-width="' . esc_attr( $embed_width ) . '" data-height="' . esc_attr( $embed_height ) . '"></div>';
978
+ }
979
+ echo '</div>';
980
+ }
981
+ }
982
+ if ( 'album_photos' === ! $fb_shortcode['type'] ) {
983
+ echo '<div class="fts-jal-fb-description-wrap" style="display:none">';
984
+ // Output Photo Name.
985
+ $fb_name ? $this->fts_facebook_post_name( $fb_link, $fb_name, $fb_type ) : '';
986
+ // Output Photo Caption.
987
+ $fb_caption ? $this->fts_facebook_post_cap( $fb_caption, $fb_shortcode, $fb_type ) : '';
988
+ // Output Photo Description.
989
+ $fb_description ? $this->fts_facebook_post_desc( $fb_description, $fb_shortcode, $fb_type, null, $fb_by ) : '';
990
+ echo '<div class="fts-clear"></div></div>';
991
+ }
992
+ echo '<div class="fts-clear"></div></div>';
993
+ break;
994
+
995
+ // START ALBUM POST.
996
+ case 'app':
997
+ case 'cover':
998
+ case 'profile':
999
+ case 'mobile':
1000
+ case 'wall':
1001
+ case 'normal':
1002
+ case 'album':
1003
+ echo '<div class="fts-jal-fb-link-wrap fts-album-photos-wrap"';
1004
+ if ( 'album_photos' === $fb_shortcode['type'] || 'albums' === $fb_shortcode['type'] ) {
1005
+ echo ' style="line-height:' . esc_attr( $fb_shortcode['image_height'] ) . ' !important;"';
1006
+ }
1007
+ echo '>';
1008
+
1009
+ // echo '<pre>rrr';
1010
+ // print_r($fb_album_cover);
1011
+ // echo '</pre>';
1012
+ // Output Photo Picture.
1013
+
1014
+ // if ( $fb_post_object_id ) {
1015
+ // if ( $fb_post_object_id ) {
1016
+
1017
+ $photo_source_final = isset( $post_data->attachments->data[0]->media->image->src ) ? $post_data->attachments->data[0]->media->image->src : 'https://graph.facebook.com/' . $fb_post_object_id . '/picture';
1018
+
1019
+ // if we have more than one attachment we get the first image width and set that for the max width.
1020
+ $fts_fb_image_count = isset( $post_data->attachments->data[0]->subattachments->data ) ? count( $post_data->attachments->data[0]->subattachments->data ) : '0';
1021
+ // TESTING: lets see how many images are being output per post.
1022
+ // echo $fts_fb_image_count;.
1023
+ // echo $fts_fb_image_count;.
1024
+ if ( '0' === $fts_fb_image_count || '1' === $fts_fb_image_count || $fts_fb_image_count > 2 ) {
1025
+
1026
+ // echo $fts_fb_image_count;.
1027
+ echo '<a href="' . ( isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ? esc_url( $photo_source_final ) : esc_url( $fb_link ) ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-picture fts-fb-large-photo"><img border="0" alt="' . esc_attr( $post_data->from->name ) . '" src="' . esc_url( $photo_source_final ) . '"></a>';
1028
+
1029
+ }
1030
+
1031
+ if ( '' !== $fb_picture_gallery1 ) {
1032
+
1033
+ // we count the number of attachments in the subattachments->data portion of the array and count the objects http://php.net/manual/en/function.count.php.
1034
+ $fts_fb_image_counter = $fts_fb_image_count - 3;
1035
+
1036
+ $fts_fb_image_count_check = $fts_fb_image_count < 3 ? ' fts-more-images-tint' : '';
1037
+
1038
+ $fb_picture_gallery1_check = '' === $fb_picture_gallery2 ? '100%;' : $fb_picture_gallery0_width . 'px';
1039
+ // if we only have 2 photos we show them side by side.
1040
+ $fb_picture_gallery2_check = '' === $fb_picture_gallery2 ? ' fts-more-photos-auto-width' : '';
1041
+ // if we have 3 photos we add this class so we can make the 2 attachments below the large image will fit side by side.
1042
+ $fb_picture_gallery3_check = '' === $fb_picture_gallery3 && '' !== $fb_picture_gallery2 ? ' fts-more-photos-three-photo-wrap' : '';
1043
+
1044
+ $columns_css = '';
1045
+
1046
+ // print $fts_fb_image_count;.
1047
+ if ( 2 === $fts_fb_image_count ) {
1048
+ $columns = '2';
1049
+ $columns_css = 'fts-more-photos-2-or-3-photos ';
1050
+ $morethan3 = 'fts-2-photos ';
1051
+ } elseif ( 3 === $fts_fb_image_count ) {
1052
+ $columns = '2';
1053
+ $columns_css = 'fts-more-photos-2-or-3-photos ';
1054
+ $morethan3 = 'fts-3-photos ';
1055
+ } elseif ( $fts_fb_image_count >= 4 ) {
1056
+ $columns = '3';
1057
+ $columns_css = 'fts-more-photos-4-photos ';
1058
+ $morethan3 = 'fts-4-photos ';
1059
+ }
1060
+
1061
+ echo '<div class="fts-clear"></div><div class="' . esc_attr( $columns_css . 'fts-fb-more-photos-wrap fts-facebook-inline-block-centered' . $fb_picture_gallery2_check . $fb_picture_gallery3_check ) . '" style="max-width:' . esc_attr( $fb_picture_gallery1_check ) . '" data-ftsi-id=' . esc_attr( $fts_dynamic_vid_name_string ) . ' data-ftsi-columns="' . esc_attr( $columns ) . '" data-ftsi-margin="1px" data-ftsi-force-columns="yes">';
1062
+ }
1063
+ if ( 2 === $fts_fb_image_count ) {
1064
+ echo '<a href="' . ( isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ? esc_url( $photo_source_final ) : esc_url( $fb_link ) ) . '" target="_blank" rel="noreferrer" class="slicker-facebook-placeholder fts-fb-thumbs-wrap ' . esc_attr( $morethan3 ) . 'fts-fb-thumb-zero-wrap fts-fb-large-photo" style="background:url(' . esc_url( $photo_source_final ) . ');" title="' . esc_attr( $fb_pictureGalleryDescription0 ) . '" aria-label="' . esc_attr( $fb_pictureGalleryDescription0 ) . '"></a>';
1065
+
1066
+ }
1067
+ if ( '' !== $fb_picture_gallery1 ) {
1068
+ echo '<a href="' . ( isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ? esc_url( $fb_picture_gallery1 ) : esc_url( $fb_picture_gallery_link1 ) ) . '" target="_blank" rel="noreferrer" class="slicker-facebook-placeholder fts-fb-thumbs-wrap ' . esc_attr( $morethan3 ) . 'fts-fb-thumb-zero-wrap fts-fb-large-photo" style="background:url(' . esc_url( $fb_picture_gallery1 ) . ');" title="' . esc_attr( $fb_pictureGalleryDescription1 ) . '" aria-label="' . esc_attr( $fb_pictureGalleryDescription1 ) . '"></a>';
1069
+
1070
+ if ( '' !== $fb_picture_gallery2 ) {
1071
+ echo '<a href="' . ( isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ? esc_url( $fb_picture_gallery2 ) : esc_url( $fb_picture_gallery_link2 ) ) . '" target="_blank" rel="noreferrer" class="fts-2-or-3-photos slicker-facebook-placeholder fts-fb-thumbs-wrap ' . esc_attr( $morethan3 ) . 'fts-fb-thumb-one-wrap fts-fb-large-photo" style="background:url(' . esc_url( $fb_picture_gallery2 ) . ');" title="' . esc_attr( $fb_pictureGalleryDescription1 ) . '" aria-label="' . esc_attr( $fb_pictureGalleryDescription1 ) . '"></a>';
1072
+
1073
+ }
1074
+ if ( '' !== $fb_picture_gallery3 ) {
1075
+ echo '<a href="' . ( isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ? esc_url( $fb_picture_gallery3 ) : esc_url( $fb_picture_gallery_link3 ) ) . '" target="_blank" rel="noreferrer" class="slicker-facebook-placeholder fts-fb-thumbs-wrap ' . esc_attr( $morethan3 ) . 'fts-fb-thumb-two-wrap fts-fb-large-photo' . esc_attr( $fts_fb_image_count_check ) . '" style="background:url(' . esc_url( $fb_picture_gallery3 ) . ');" title="' . esc_attr( $fb_pictureGalleryDescription2 ) . '" aria-label="' . esc_attr( $fb_pictureGalleryDescription2 ) . '"><div class="fts-image-count-tint-underlay"></div><div class="fts-image-count"><span>+</span>' . esc_html( $fts_fb_image_counter ) . '</div></a>';
1076
+ }
1077
+ }
1078
+ if ( '' !== $fb_picture_gallery1 ) {
1079
+ echo '</div>';
1080
+ }
1081
+ // }
1082
+ // else {
1083
+ // echo '<a href="' . ( isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ? esc_url( $photo_source_final ) : esc_url( $fb_link ) ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-picture fts-fb-large-photo"><img border="0" alt="' . esc_attr( $post_data->from->name ) . '" src="' . esc_url( $photo_source_final ) . '" title="' . $fb_pictureGalleryDescription0 . '" aria-label="' . $fb_pictureGalleryDescription0 . '"></a>';
1084
+ // }
1085
+ // }
1086
+ if ( 'albums' === $fb_shortcode['type'] ) {
1087
+ $this->fts_facebook_post_photo( $fb_link, $fb_shortcode, $post_data->from->name, $fb_album_cover );
1088
+ }
1089
+ echo '<div class="slicker-facebook-album-photoshadow"></div>';
1090
+ if ( 'albums' === ! $fb_shortcode['type'] ) {
1091
+ echo '<div class="fts-jal-fb-description-wrap">';
1092
+ // Output Photo Name.
1093
+ $fb_name ? $this->fts_facebook_post_name( $fb_link, $fb_name, $fb_type ) : '';
1094
+ // Output Photo Caption.
1095
+ $fb_caption ? $this->fts_facebook_post_cap( $fb_caption, $fb_shortcode, $fb_type ) : '';
1096
+ // Output Photo Description.
1097
+ $fb_description ? $this->fts_facebook_post_desc( $fb_description, $fb_shortcode, $fb_type, null, $fb_by ) : '';
1098
+ echo '<div class="fts-clear"></div></div>';
1099
+ }
1100
+ echo '<div class="fts-clear"></div></div>';
1101
+ break;
1102
+
1103
+ }
1104
+ // This puts the video in a popup instead of displaying it directly on the page.
1105
+ if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ) {
1106
+ // Post Comments.
1107
+ echo '<div class="fts-fb-comments-wrap">';
1108
+ $hide_comments_popup = isset( $fb_shortcode['hide_comments_popup'] ) ? $fb_shortcode['hide_comments_popup'] : 'no';
1109
+ if ( isset( $lcs_array['comments_thread']->data ) && ! empty( $lcs_array['comments_thread']->data ) && 'yes' !== $hide_comments_popup || isset( $lcs_array['comments_thread']->data ) && ! empty( $lcs_array['comments_thread']->data ) && empty( $hide_comments_popup ) ) {
1110
+ // Post Comments.
1111
+ echo '<div class="fts-fb-comments-content fts-comments-post-' . esc_attr( $fb_post_id ) . '">';
1112
+
1113
+ foreach ( $lcs_array['comments_thread']->data as $comment ) {
1114
+ if ( ! empty( $comment->message ) ) {
1115
+ echo '<div class="fts-fb-comment fts-fb-comment-' . esc_attr( $comment->id ) . '">';
1116
+ // User Profile Img.
1117
+ // Not having page public content access persmission anymore is not allowing us to get profile pics anymore, and the link to personal accounts won't work anymore either for people posting to our page.
1118
+ // $avatar_id = isset( $comment->from->id ) ? 'https://graph.facebook.com/'.$comment->from->id.'/picture?redirect=1&type=square' : plugin_dir_url( dirname( __FILE__ ) ) . 'images/slick-comment-pic.png';
1119
+ $avatar_id = plugin_dir_url( __DIR__ ) . 'images/slick-comment-pic.png';
1120
+ echo '<img class="fts-fb-comment-user-pic" src="' . esc_url( $avatar_id ) . '"/>';
1121
+ echo '<div class="fts-fb-comment-msg">';
1122
+ if ( isset( $comment->from->name ) ) {
1123
+ echo '<span class="fts-fb-comment-user-name">' . esc_html( $comment->from->name ) . '</span> ';
1124
+ }
1125
+ echo esc_html( $comment->message ) . '</div>';
1126
+
1127
+ // Comment Message.
1128
+ echo '</div>';
1129
+ }
1130
+ }
1131
+ echo '</div>';
1132
+
1133
+ // echo '<pre>';
1134
+ // print_r( $lcs_array['comments_thread']->data );
1135
+ // echo '</pre>';
1136
+ }
1137
+ echo '</div><!-- END Comments Wrap -->';
1138
+ }
1139
+
1140
+ // filter messages to have urls.
1141
+ // Output Message For combined feeds in the bottom.
1142
+ if ( isset( $fb_shortcode['show_media'] ) && 'top' === $show_media ) {
1143
+
1144
+ if ( isset( $fb_shortcode['show_social_icon'] ) && 'right' === $fb_shortcode['show_social_icon'] ) {
1145
+ echo '<div class="fts-mashup-icon-wrap-right fts-mashup-facebook-icon"><a href="' . esc_url( 'https://www.facebook.com/' . $from_id_picture ) . '" target="_blank" rel="noreferrer"></a></div>';
1146
+ }
1147
+ // show icon.
1148
+ if ( isset( $fb_shortcode['show_social_icon'] ) && 'left' === $fb_shortcode['show_social_icon'] ) {
1149
+ echo '<div class="fts-mashup-icon-wrap-left fts-mashup-facebook-icon"><a href="' . esc_url( 'https://www.facebook.com/' . $from_id_picture ) . '" target="_blank" rel="noreferrer"></a></div>';
1150
+ }
1151
+ echo '<div class="fts-jal-fb-top-wrap ' . esc_attr( $hide_date_likes_comments ) . '" style="display:block !important;">';
1152
+ echo '<div class="fts-jal-fb-user-thumb">';
1153
+
1154
+ $avatar_id = plugin_dir_url( __DIR__ ) . 'images/slick-comment-pic.png';
1155
  $profile_photo_exists_check = isset( $post_data->fts_profile_pic_url ) && strpos( $post_data->fts_profile_pic_url, 'profilepic' ) !== false ? $post_data->fts_profile_pic_url : $avatar_id;
1156
+ echo ( 'reviews' === esc_attr( $fb_shortcode['type'] ) ? '' : '<a href="' . esc_url( 'https://www.facebook.com/' . $from_id_picture ) . '" target="_blank" rel="noreferrer">' ) . '<img border="0" alt="' . ( 'reviews' === esc_attr( $fb_shortcode['type'] ) ? esc_attr( $post_data->reviewer->name ) : esc_attr( $post_data->from->name ) ) . '" src="' . ( 'reviews' === esc_attr( $fb_shortcode['type'] ) ? esc_url( $profile_photo_exists_check ) . '"/>' : 'https://graph.facebook.com/' . esc_attr( $from_id_picture ) ) . ( 'reviews' === esc_attr( $fb_shortcode['type'] ) ? '' : '/picture"/></a>' );
1157
  echo '</div>';
1158
 
1159
+ // UserName.
1160
+ echo '<span class="fts-jal-fb-user-name"><a href="' . esc_url( 'https://www.facebook.com/' . $from_id_picture ) . '" target="_blank" rel="noreferrer">' . esc_html( $post_data->from->name ) . '</a>' . esc_html( $fb_hide_shared_by_etc_text ) . '</span>';
1161
+
1162
+ // tied to date function.
1163
+ $feed_type = 'facebook';
1164
+ $times = $custom_time_format;
1165
+ $fts_final_date = $this->fts_custom_date( $times, $feed_type );
1166
+ // PostTime.
1167
+ echo '<span class="fts-jal-fb-post-time">' . $fts_final_date . '</span><div class="fts-clear"></div>';
1168
+
1169
+ if ( ! empty( $fb_places_id ) ) {
1170
+ $this->feed_location_option( $fb_places_id, $fb_name, $fb_places_name );
1171
+ }
1172
+
1173
+ // here we trim the words for the premium version. The $fb_shortcode['words'] string actually comes from the javascript.
1174
+ if ( is_plugin_active( 'feed-them-social-combined-streams/feed-them-social-combined-streams.php' ) && array_key_exists( 'words', $fb_shortcode ) || is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && array_key_exists( 'words', $fb_shortcode ) ) {
1175
+ $more = isset( $more ) ? $more : '';
1176
+ $trimmed_content = $this->fts_custom_trim_words( $fb_message, $fb_shortcode['words'], $more );
1177
+
1178
+ echo '<div class="fts-jal-fb-message">';
1179
+
1180
+ echo esc_html( $fb_title_job_opening );
1181
+ echo ! empty( $trimmed_content ) ? $trimmed_content : '';
1182
+ echo '<div class="fts-clear"></div></div> ';
1183
+
1184
+ } else {
1185
+ $fb_final_message = $this->fts_facebook_tag_filter( $fb_message );
1186
+ echo '<div class="fts-jal-fb-message">';
1187
+ echo nl2br( $fb_final_message );
1188
+ echo '<div class="fts-clear"></div></div>';
1189
+ }
1190
+ echo '</div>';
1191
+
1192
+ }
1193
+
1194
+ echo '<div class="fts-clear"></div>';
1195
+ echo '</div>';
1196
+ $fb_post_single_id = isset( $fb_post_single_id ) ? $fb_post_single_id : '';
1197
+ $single_event_id = isset( $single_event_id ) ? $single_event_id : '';
1198
+ $this->fts_facebook_post_see_more( $fb_link, $lcs_array, $fb_type, $fb_post_id, $fb_shortcode, $fb_post_user_id, $fb_post_single_id, $single_event_id, $post_data );
1199
+ echo '<div class="fts-clear"></div>';
1200
+ echo '</div>';
1201
+
1202
+ }//end feed_post_types()
1203
+ }//end class
feeds/facebook/class-fts-facebook-feed.php CHANGED
@@ -7,2251 +7,2263 @@
7
  * @since 1.9.6
8
  */
9
  class FTS_Facebook_Feed extends feed_them_social_functions {
10
- /**
11
- * Construct
12
- *
13
- * Facebook Feed constructor.
14
- *
15
- * @since 1.9.6
16
- */
17
- public function __construct() {
18
- add_shortcode( 'fts_facebook_group', array( $this, 'fts_fb_func' ) );
19
- add_shortcode( 'fts_facebook_page', array( $this, 'fts_fb_func' ) );
20
- add_shortcode( 'fts_facebook_event', array( $this, 'fts_fb_func' ) );
21
- add_shortcode( 'fts_facebook', array( $this, 'fts_fb_func' ) );
22
- add_action( 'wp_enqueue_scripts', array( $this, 'fts_fb_head' ) );
23
- }
24
-
25
- /**
26
- * FTS FB Head
27
- *
28
- * Add Styles and Scripts functions.
29
- *
30
- * @since 1.9.6
31
- */
32
- public function fts_fb_head() {
33
- wp_enqueue_style( 'fts-feeds', plugins_url( 'feed-them-social/feeds/css/styles.css' ), array(), FTS_CURRENT_VERSION, false );
34
-
35
- if ( is_plugin_active( 'feed-them-social/feed-them.php' ) && is_plugin_active( 'feed-them-carousel-premium/feed-them-carousel-premium.php' ) && is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) ) {
36
- wp_enqueue_script( 'fts-feeds', plugins_url( 'feed-them-carousel-premium/feeds/js/jquery.cycle2.js' ), array(), FTS_CURRENT_VERSION, false );
37
- }
38
- }
39
-
40
- /**
41
- * Date Sort
42
- *
43
- * Date sort option for multiple feeds in a shortcode.
44
- *
45
- * @param string $a First Date.
46
- * @param string $b Second Date.
47
- * @return false|int
48
- * @since 1.9.6
49
- */
50
- public function dateSort( $a, $b ) {
51
- $date_a = strtotime( $a->created_time );
52
- $date_b = strtotime( $b->created_time );
53
- return ( $date_b - $date_a );
54
- }
55
-
56
-
57
- /**
58
- * FTS FB Func
59
- *
60
- * Display Facebook Feed.
61
- *
62
- * @param string $atts Shortcode attributes.
63
- * @return string
64
- * @since 1.9.6
65
- */
66
- public function fts_fb_func( $atts ) {
67
- // masonry snippet in fts-global.
68
- wp_enqueue_script( 'fts-global', plugins_url( 'feed-them-social/feeds/js/fts-global.js' ), array( 'jquery' ), FTS_CURRENT_VERSION, false );
69
- $developer_mode = 'on';
70
- // Make sure everything is reset.
71
- include_once ABSPATH . 'wp-admin/includes/plugin.php';
72
- // Eventually add premium page file.
73
- if ( is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) ) {
74
-
75
- $fts_facebook_reviews = new FTS_Facebook_Reviews();
76
- $review_atts = $fts_facebook_reviews->shortcode_attributes();
77
- $fb_shortcode = shortcode_atts( $review_atts, $atts );
78
- // Load up some scripts for popup.
79
- $this->load_popup_scripts( $fb_shortcode );
80
- } elseif ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) ) {
81
- include WP_PLUGIN_DIR . '/feed-them-premium/feeds/facebook/facebook-premium-feed.php';
82
- // Doing this to phase out the invalid snake case.
83
- $fb_shortcode = $FB_Shortcode;
84
- // Load up some scripts for popup.
85
- $this->load_popup_scripts( $fb_shortcode );
86
- } elseif ( is_plugin_active( 'feed-them-social-combined-streams/feed-them-social-combined-streams.php' ) && ! is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) ) {
87
- // Doing this to phase out the invalid snake case.
88
- $fb_shortcode = $FB_Shortcode;
89
- $fb_shortcode = shortcode_atts(
90
- array(
91
- 'id' => '',
92
- 'type' => '',
93
- 'posts' => '',
94
- 'posts_displayed' => '',
95
- 'height' => '',
96
- 'album_id' => '',
97
- 'image_width' => '',
98
- 'image_height' => '',
99
- 'space_between_photos' => '',
100
- 'hide_date_likes_comments' => '',
101
- 'center_container' => '',
102
- 'image_stack_animation' => '',
103
- 'image_position_lr' => '',
104
- 'image_position_top' => '',
105
- 'hide_comments_popup' => '',
106
- // only works with combined FB streams otherwise you need the premium version.
107
- 'popup' => '',
108
- 'words' => '',
109
- 'grid' => '',
110
- 'colmn_width' => '',
111
- 'space_between_posts' => '',
112
- // new show media on top options.
113
- 'show_media' => '',
114
- 'show_date' => '',
115
- 'show_name' => '',
116
- // 'access_token' => '',
117
- ),
118
- $atts
119
- );
120
- if ( null === $fb_shortcode['posts'] ) {
121
- $fb_shortcode['posts'] = '6';
122
- }
123
- } else {
124
- $fb_shortcode = shortcode_atts(
125
- array(
126
- 'id' => '',
127
- 'type' => '',
128
- 'posts' => '',
129
- 'description' => 'yes',
130
- 'posts_displayed' => '',
131
- 'height' => '',
132
- 'album_id' => '',
133
- 'image_width' => '',
134
- 'image_height' => '',
135
- 'space_between_photos' => '',
136
- 'hide_date_likes_comments' => '',
137
- 'center_container' => '',
138
- 'image_stack_animation' => '',
139
- 'image_position_lr' => '',
140
- 'image_position_top' => '',
141
- 'hide_comments_popup' => '',
142
- 'access_token' => '',
143
- ),
144
- $atts
145
- );
146
- if ( null === $fb_shortcode['posts'] ) {
147
- $fb_shortcode['posts'] = '6';
148
- }
149
- }
150
-
151
- if ( 'album_videos' === $fb_shortcode['type'] ) {
152
- $fb_shortcode['type'] = 'album_photos';
153
- $fb_shortcode['video_album'] = 'yes';
154
- $fb_shortcode['album_id'] = 'photo_stream';
155
- if ( isset( $fb_shortcode['loadmore_btn_maxwidth'] ) && ! empty( $fb_shortcode['loadmore_btn_maxwidth'] ) ) {
156
- $fb_shortcode['loadmore'] = 'button';
157
- }
158
- }
159
-
160
- if ( ! is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && ! is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && ! is_plugin_active( 'feed-them-social-combined-streams/feed-them-social-combined-streams.php' ) && $fb_shortcode['posts'] > '6' ) {
161
- $fb_shortcode['posts'] = '6';
162
- }
163
-
164
- // Get Access Token.
165
- $access_token = isset( $fb_shortcode['access_token'] ) ? $fb_shortcode['access_token'] : '';
166
- if ( ! empty( $access_token ) ) {
167
- $access_token = $fb_shortcode['access_token'];
168
- } else {
169
- $access_token = $this->get_access_token();
170
- }
171
-
172
- // UserName?.
173
- if ( ! $fb_shortcode['id'] ) {
174
- return 'Please enter a username for this feed.';
175
- }
176
- if ( 'reviews' === $fb_shortcode['type'] && ! is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) ) {
177
- return '<div style="clear:both; padding:15px 0;">You must have FTS Facebook Reviews extension active to see this feed.</div>';
178
- }
179
-
180
- $type = isset( $fb_shortcode['type'] ) ? $fb_shortcode['type'] : '';
181
- if ( 'group' === $type || 'page' === $type || 'event' === $type ) {
182
-
183
- // EMPTY FACEBOOK POSTS OFFSET AND COUNT.
184
- // Option Now Being Removed from here and the Facebook Settings Page.
185
- // Setting it to blank so no matter what it will never error get_option('fb_count_offset');.
186
- $fb_count_offset = '';
187
-
188
- // View Link.
189
- $fts_view_fb_link = '';
190
- // Get Cache Name.
191
- $fb_cache_name = '';
192
- // Get language.
193
- $language = '';
194
-
195
- // Get Response (AKA Page & Feed Information) ERROR CHECK inside this function.
196
- $response2 = $this->get_facebook_feed_response( $fb_shortcode, $fb_cache_name, $access_token, $language );
197
-
198
- // Test to see if the re-sort date option is working from function above.
199
- // print $this->dateSort;.
200
- $feed_data_check = json_decode( $response2['feed_data'] );
201
-
202
- // SHOW THE REGULAR FEEDS PRINT_R
203
- // echo '<pre>';
204
- // print_r($feed_data_check);
205
- // echo '</pre>';
206
- // $idNew = array();
207
- // $idNew = explode(',', $fb_shortcode['id']);
208
- // Testing options before foreach loop
209
- // $idNew = 'tonyhawk';
210
- // print_r($feed_data_check->$idNew->data);.
211
- if ( is_plugin_active( 'feed-them-social-combined-streams/feed-them-social-combined-streams.php' ) ) {
212
- $fts_count_ids = substr_count( $fb_shortcode['id'], ',' );
213
- } else {
214
- $fts_count_ids = '';
215
- }
216
-
217
- if ( isset( $feed_data_check->data ) ) {
218
- if ( $fts_count_ids >= 1 && 'reviews' !== $fb_shortcode['type'] ) {
219
- $fts_list_arrays = array();
220
- foreach ( $feed_data_check as $feed_data_name ) {
221
-
222
- if ( isset( $feed_data_name->data ) ) {
223
- $fts_list_arrays = array_merge_recursive( $fts_list_arrays, $feed_data_name->data );
224
- }
225
- // var_dump( $fts_list_arrays[$i]);.
226
- }
227
- $merged_array['data'] = $fts_list_arrays;
228
- $feed_data_check = (object) $merged_array;
229
- }
230
-
231
- // Test the created dataes are being sorted properly
232
- // foreach($merged_array['data'] as $newSort) {
233
- // print date("jS F, Y", strtotime($newSort->created_time));
234
- // print '<br/>';
235
- // }.
236
- $set_zero = 0;
237
- foreach ( $feed_data_check->data as $post_count ) {
238
-
239
- $fb_message = isset( $post_count->message ) ? $post_count->message : '';
240
- $fb_story = isset( $post_count->story ) ? $post_count->story : '';
241
- $fb_type = isset( $post_count->type ) ? $post_count->type : '';
242
- $fb_status_type = isset( $post_count->status_type ) ? $post_count->status_type : '';
243
-
244
- // This is the method to skip empty posts or posts that are simply about changing settings or other non important post types
245
- // We will count all the ones that are like this and add that number to the output of posts to offset the posts we are filtering out. Line 278 needs the same treatment of if options.
246
- if ( 'status' === $fb_type && empty( $fb_message ) && empty( $fb_story ) || 'event' === $fb_type || 'event' === $fb_type && false !== strpos( $fb_story, 'shared their event' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'changed the name of the event to' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'changed the privacy setting' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'an admin of the group' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'created the group' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'added an event' ) || 'event' === $fb_type && false !== strpos( $fb_story, 'added an event' ) ) {
247
- $set_zero++;
248
- } elseif ( '0' === $feed_data_check->data ) {
249
- // If more than the 5 posts(default in free) or the post= from shortcode is set to the amount of posts that are being filtered above we will add 7 to the post count to try and get at some posts.
250
- // This will only happen for Page and Group feeds.
251
- $set_zero = '7';
252
- }
253
- }// END POST foreach.
254
-
255
- // Result of the foreach loop above minus the empty posts and offset by those posts the actual number of posts entered is shown
256
- // $fb_shortcode['posts'] = $result;.
257
- if ( ! empty( $fb_count_offset ) ) {
258
- $set_zero = $fb_count_offset;
259
- $unset_count = $fb_shortcode['posts'] + $set_zero;
260
- $fb_shortcode['posts'] = $unset_count;
261
- } else {
262
- $unset_count = $fb_shortcode['posts'] + $set_zero;
263
- $fb_shortcode['posts'] = $unset_count;
264
- }
265
-
266
- // SHOW THE $feed_data_check PRINT_R
267
- // echo '<pre>';
268
- // print_r($feed_data_check);
269
- // echo '</pre>, ';.
270
- }
271
- // END.
272
- }
273
-
274
- ob_start();
275
- // Uncomment these for testing purposes to see the actual count and the offset count
276
- // print $set_zero;
277
- // print $fb_shortcode['posts'];
278
- // print $fb_type;
279
- // View Link.
280
- $fts_view_fb_link = $this->get_view_link( $fb_shortcode );
281
- // Get Cache Name.
282
- $fb_cache_name = $this->get_fb_cache_name( $fb_shortcode );
283
- // Get language.
284
- $language = $this->get_language( $fb_shortcode );
285
- if ( 'reviews' !== $fb_shortcode['type'] ) {
286
- // Get Response (AKA Page & Feed Information) ERROR CHECK inside this function.
287
- $response = $this->get_facebook_feed_response( $fb_shortcode, $fb_cache_name, $access_token, $language );
288
- // Json decode data and build it from cache or response.
289
- $page_data = json_decode( $response['page_data'] );
290
- $feed_data = json_decode( $response['feed_data'] );
291
- }
292
-
293
- if ( is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && true == get_option( 'fts_facebook_custom_api_token_biz' ) && 'reviews' === $fb_shortcode['type'] ||
294
- is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && ! empty( $fb_shortcode['token'] ) && 'reviews' === $fb_shortcode['type'] ||
295
- is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && ! empty( $fb_shortcode['access_token'] ) && 'reviews' === $fb_shortcode['type'] ) {
296
-
297
- if ( 'yes' === $fb_shortcode['remove_reviews_no_description'] && ! isset( $_GET['load_more_ajaxing'] ) ) {
298
-
299
- $fts_facebook_reviews = new FTS_Facebook_Reviews();
300
- $no_description_count = $fts_facebook_reviews->review_count_check( $fb_shortcode );
301
-
302
- // testing purposes
303
- // print ''. $no_description_count - $fb_shortcode['posts'] .' = The amount of posts with no review text.';
304
- // this count includes our original posts count + the amount of posts we found with no description.
305
- $fb_shortcode['posts'] = $no_description_count;
306
- }
307
- if ( ! empty( $fb_shortcode['token'] ) ) {
308
- $biz_access_token = $fb_shortcode['token'];
309
- } elseif ( ! empty( $fb_shortcode['access_token'] ) ) {
310
- $biz_access_token = $fb_shortcode['access_token'];
311
- } else {
312
- $biz_access_token = get_option( 'fts_facebook_custom_api_token_biz' );
313
- }
314
-
315
- // Get Response (AKA Page & Feed Information) ERROR CHECK inside this function.
316
- $response = $this->get_facebook_feed_response( $fb_shortcode, $fb_cache_name, $biz_access_token, $language );
317
-
318
- $feed_data = json_decode( $response['feed_data'] );
319
-
320
- $feed_data = (object) $feed_data;
321
- // Add Feed Type to post array.
322
- // SHOW THE REVIEWS FEED PRINT_R
323
- // echo '<pre>';
324
- // print_r($feed_data );
325
- // echo '</pre>';
326
- if ( 'yes' === $fb_shortcode['remove_reviews_no_description'] ) {
327
- // $no_description_count2 = 0;.
328
- foreach ( $feed_data->data as $k => $v ) {
329
- if ( ! isset( $v->review_text ) ) {
330
- // print $v->reviewer->name . ' (Key# ' . $k . ') : Now Unset from array<br/>';.
331
- unset( $feed_data->data[ $k ] );
332
- // $no_description_count2++;.
333
- }
334
- }
335
- }
336
- $ratings_data = json_decode( $response['ratings_data'] );
337
-
338
- // SHOW THE REVIEWS RATING INFO PRINT_R
339
- // echo '<pre>';
340
- // print_r($ratings_data );
341
- // echo '</pre>';.
342
- // Add fts_profile_pic_url to the array so we can show profile photos for reviews and comments in popup
343
- foreach ( $feed_data->data as $post_array ) {
344
-
345
- $the_image = 'https://graph.facebook.com/' . $post_array->reviewer->id . '/picture?redirect=false&access_token=' . $biz_access_token . '';
346
-
347
- $profile_pic_response = wp_remote_get( $the_image );
348
- $profile_pic_data = wp_remote_retrieve_body( $profile_pic_response );
349
- $profile_pic_output = json_decode( $profile_pic_data );
350
-
351
- // echo '<pre>';
352
- // print_r($profile_pic_output->data->url);
353
- // echo '</pre>';
354
- $post_array->fts_profile_pic_url = $profile_pic_output->data->url;
355
- }
356
- }
357
-
358
- if ( is_plugin_active( 'feed-them-social-combined-streams/feed-them-social-combined-streams.php' ) ) {
359
- $fts_count_ids = substr_count( $fb_shortcode['id'], ',' );
360
- } else {
361
- $fts_count_ids = '';
362
- }
363
-
364
- if ( $fts_count_ids >= 1 && 'reviews' !== $fb_shortcode['type'] ) {
365
-
366
- $fts_list_arrays = array();
367
- foreach ( $feed_data as $feed_data_name ) {
368
-
369
- $fts_list_arrays = array_merge_recursive( $fts_list_arrays, $feed_data_name->data );
370
- // var_dump( $fts_list_arrays[$i]);.
371
- }
372
- // Sort the array using the call back function.
373
- usort( $fts_list_arrays, array( $this, 'dateSort' ) );
374
-
375
- $merged_array['data'] = $fts_list_arrays;
376
- $feed_data = (object) $merged_array;
377
- }
378
- // SHOW THE REGULAR FEEDS PRINT_R (WORKS FOR VIDEOS AND ALBUMS TOO)
379
- // echo '<pre>';
380
- // print_r($feed_data );
381
- // echo '</pre>';
382
- // If No Response or Error then return.
383
- if ( is_array( $response ) && isset( $response[0] ) && isset( $response[1] ) && false === $response[0] ) {
384
- return $response[1];
385
- }
386
-
387
- if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) ) {
388
- // Make sure it's not ajaxing and we will allow the omition of certain album covers from the list by using omit_album_covers=0,1,2,3 in the shortcode.
389
- if ( ! isset( $_GET['load_more_ajaxing'] ) && 'albums' === $fb_shortcode['type'] ) {
390
-
391
- // omit_album_covers=0,1,2,3 for example.
392
- $omit_album_covers = $fb_shortcode['omit_album_covers'];
393
- $omit_album_covers_new = array();
394
- $omit_album_covers_new = explode( ',', $omit_album_covers );
395
- foreach ( $feed_data->data as $post_data ) {
396
- foreach ( $omit_album_covers_new as $omit ) {
397
- unset( $feed_data->data[ $omit ] );
398
- }
399
- }
400
- }
401
- }
402
- // Reviews Rating Filter.
403
- if ( is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && 'reviews' === $fb_shortcode['type'] ) {
404
- foreach ( $feed_data->data as $key => $post_data ) {
405
- // we are not going to show the unrecommended reviews in the feed at this point, no options in our plugin srl 8-28-18.
406
- if ( isset( $post_data->rating ) && $post_data->rating < $fb_shortcode['reviews_type_to_show'] || isset( $post_data->recommendation_type ) && 'negative' === $post_data->recommendation_type ) {
407
- unset( $feed_data->data[ $key ] );
408
- }
409
- }
410
- }
411
-
412
- // Make sure it's not ajaxing.
413
- if ( ! isset( $_GET['load_more_ajaxing'] ) ) {
414
- // Get Response (AKA Page & Feed Information).
415
- $_REQUEST['fts_dynamic_name'] = sanitize_key( $this->fts_rand_string( 10 ) . '_' . $fb_shortcode['type'] );
416
- // Create Dynamic Class Name.
417
- $fts_dynamic_class_name = $this->get_fts_dynamic_class_name();
418
- // SOCIAL BUTTON.
419
- if ( ! $fts_count_ids >= 1 ) {
420
- $this->fb_social_btn_placement( $fb_shortcode, $access_token, 'fb-like-top-above-title' );
421
- }
422
-
423
- if ( 'reviews' !== $fb_shortcode['type'] ) {
424
- $page_data->description = isset( $page_data->description ) ? $page_data->description : '';
425
- $page_data->name = isset( $page_data->name ) ? $page_data->name : '';
426
- }
427
- // fts-fb-header-wrapper (for grid).
428
- echo isset( $fb_shortcode['grid'] ) && 'yes' !== $fb_shortcode['grid'] && 'album_photos' !== $fb_shortcode['type'] && 'albums' !== $fb_shortcode['type'] ? '<div class="fts-fb-header-wrapper">' : '';
429
-
430
- // Header.
431
- echo '<div class="fts-jal-fb-header">';
432
-
433
- if ( is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && isset( $fb_shortcode['overall_rating'] ) && 'yes' === $fb_shortcode['overall_rating'] ) {
434
-
435
- // echo $this->get_facebook_overall_rating_response($fb_shortcode, $fb_cache_name, $access_token);.
436
- $fb_reviews_overall_rating_of_5_stars_text = get_option( 'fb_reviews_overall_rating_of_5_stars_text' );
437
- $fb_reviews_overall_rating_of_5_stars_text = ! empty( $fb_reviews_overall_rating_of_5_stars_text ) ? ' ' . $fb_reviews_overall_rating_of_5_stars_text : ' of 5 stars';
438
- $fb_reviews_overall_rating_reviews_text = get_option( 'fb_reviews_overall_rating_reviews_text' );
439
- $fb_reviews_overall_rating_reviews_text = ! empty( $fb_reviews_overall_rating_reviews_text ) ? ' ' . $fb_reviews_overall_rating_reviews_text : ' reviews';
440
- $fb_reviews_overall_rating_background_border_hide = get_option( 'fb_reviews_overall_rating_background_border_hide' );
441
- $fb_reviews_overall_rating_background_border_hide = ! empty( $fb_reviews_overall_rating_background_border_hide ) && 'yes' === $fb_reviews_overall_rating_background_border_hide ? ' fts-review-details-master-wrap-no-background-or-border' : '';
442
- echo '<div class="fts-review-details-master-wrap' . esc_attr( $fb_reviews_overall_rating_background_border_hide ) . '" itemscope itemtype="http://schema.org/CreativeWork"><i class="fts-review-star">' . esc_html( $ratings_data->overall_star_rating ) . ' &#9733;</i>';
443
- echo '<div class="fts-review-details-wrap" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"><div class="fts-review-details"><span itemprop="ratingValue">' . esc_html( $ratings_data->overall_star_rating ) . '</span>' . esc_html( $fb_reviews_overall_rating_of_5_stars_text ) . '</div>';
444
- echo '<div class="fts-review-details-count"><span itemprop="reviewCount">' . esc_html( $ratings_data->rating_count ) . '</span>' . esc_html( $fb_reviews_overall_rating_reviews_text ) . '</div></div></div>';
445
-
446
- }
447
- if ( 'reviews' !== $fb_shortcode['type'] ) {
448
-
449
- $fb_title_htag = get_option( 'fb_title_htag' ) ? get_option( 'fb_title_htag' ) : 'h1';
450
-
451
- if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) ) {
452
- // echo our Facebook Page Title or About Text. Commented out the group description because in the future we will be adding the about description.
453
- $fb_title_htag_size = get_option( 'fb_title_htag_size' ) ? 'font-size:' . get_option( 'fb_title_htag_size' ) . ';' : '';
454
- $fts_align_title = isset( $fb_shortcode['title_align'] ) && '' !== $fb_shortcode['title_align'] ? 'style=text-align:' . $fb_shortcode['title_align'] . ';' . $fb_title_htag_size . '' : $fb_title_htag_size;
455
- echo isset( $fb_shortcode['title'] ) && 'no' !== $fb_shortcode['title'] ? '<' . esc_html( $fb_title_htag ) . ' ' . esc_attr( $fts_align_title ) . '><a href="' . esc_url( $fts_view_fb_link ) . '" target="_blank" rel="noreferrer">' . esc_html( $page_data->name ) . '</a></' . esc_html( $fb_title_htag ) . '>' : '';
456
-
457
- } else {
458
- // echo our Facebook Page Title or About Text. Commented out the group description because in the future we will be adding the about description.
459
- $fb_title_htag_size = get_option( 'fb_title_htag_size' ) ? 'style=font-size:' . get_option( 'fb_title_htag_size' ) . ';' : '';
460
- echo '<' . esc_html( $fb_title_htag ) . ' ' . esc_attr( $fb_title_htag_size ) . '><a href="' . esc_url( $fts_view_fb_link ) . '" target="_blank" rel="noreferrer">' . esc_html( $page_data->name ) . '</a></' . esc_html( $fb_title_htag ) . '>';
461
- }
462
- // Description.
463
- echo isset( $fb_shortcode['description'] ) && 'no' !== $fb_shortcode['description'] ? '<div class="fts-jal-fb-group-header-desc">' . wp_kses(
464
- $this->fts_facebook_tag_filter( $page_data->description ),
465
- array(
466
- 'a' => array(
467
- 'href' => array(),
468
- 'title' => array(),
469
- ),
470
- 'br' => array(),
471
- 'em' => array(),
472
- 'strong' => array(),
473
- 'small' => array(),
474
- )
475
- ) . '</div>' : '';
476
- }
477
- // END Header.
478
- echo '</div>';
479
- // Close fts-fb-header-wrapper.
480
- echo isset( $fb_shortcode['grid'] ) && 'yes' !== $fb_shortcode['grid'] && 'album_photos' !== $fb_shortcode['type'] && 'albums' !== $fb_shortcode['type'] ? '</div>' : '';
481
- } //End check.
482
-
483
- // SOCIAL BUTTON.
484
- if ( ! $fts_count_ids >= 1 ) {
485
- $this->fb_social_btn_placement( $fb_shortcode, $access_token, 'fb-like-top-below-title' );
486
- }
487
-
488
- // Feed Header.
489
- // Make sure it's not ajaxing.
490
- if ( ! isset( $_GET['load_more_ajaxing'] ) ) {
491
-
492
- $fts_mashup_media_top = isset( $fb_shortcode['show_media'] ) && 'top' === $fb_shortcode['show_media'] ? 'fts-mashup-media-top ' : '';
493
- $fts_mashup_show_name = isset( $fb_shortcode['show_name'] ) && 'no' === $fb_shortcode['show_name'] ? ' fts-mashup-hide-name ' : '';
494
- $fts_mashup_show_date = isset( $fb_shortcode['show_date'] ) && 'no' === $fb_shortcode['show_date'] ? ' fts-mashup-hide-date ' : '';
495
- $fts_mashup_show_thumbnail = isset( $fb_shortcode['show_thumbnail'] ) && 'no' === $fb_shortcode['show_thumbnail'] ? ' fts-mashup-hide-thumbnail ' : '';
496
-
497
- if ( ! isset( $fb_type ) && 'albums' === $fb_shortcode['type'] || ! isset( $fb_type ) && 'album_photos' === $fb_shortcode['type'] || isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] ) {
498
-
499
- if ( isset( $fb_shortcode['video_album'] ) && 'yes' === $fb_shortcode['video_album'] ) {
500
- echo '';
501
- } elseif ( isset( $fb_shortcode['slider'] ) && 'yes' !== $fb_shortcode['slider'] && 'yes' === $fb_shortcode['image_stack_animation'] || isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] || isset( $fb_shortcode['image_stack_animation'] ) && 'yes' === $fb_shortcode['image_stack_animation'] ) {
502
- wp_enqueue_script( 'fts-masonry-pkgd', plugins_url( 'feed-them-social/feeds/js/masonry.pkgd.min.js' ), array( 'jquery' ), FTS_CURRENT_VERSION, false );
503
- echo '<script>';
504
- echo 'jQuery(window).on(\'load\', function(){';
505
- echo 'jQuery(".' . esc_js( $fts_dynamic_class_name ) . '").masonry({';
506
- echo 'itemSelector: ".fts-jal-single-fb-post"';
507
- echo '});';
508
- echo '});';
509
- echo '</script>';
510
- }
511
-
512
- if ( ! isset( $fb_type ) && 'albums' === $fb_shortcode['type'] || ! isset( $fb_type ) && 'album_photos' === $fb_shortcode['type'] && ! isset( $fb_type ) && ! isset( $fb_shortcode['slider'] ) || ! isset( $fb_type ) && 'album_photos' === $fb_shortcode['type'] && ! isset( $fb_type ) && isset( $fb_shortcode['slider'] ) && 'yes' !== $fb_shortcode['slider'] ) {
513
- echo '<div class="fts-slicker-facebook-photos fts-slicker-facebook-albums' . ( isset( $fb_shortcode['video_album'] ) && $fb_shortcode['video_album'] && 'yes' === $fb_shortcode['video_album'] ? ' popup-video-gallery-fb' : '' ) . ( isset( $fb_shortcode['image_stack_animation'] ) && 'yes' === $fb_shortcode['image_stack_animation'] ? ' masonry js-masonry' : '' ) . ( isset( $fb_shortcode['images_align'] ) && $fb_shortcode['images_align'] ? ' popup-video-gallery-align-' . esc_attr( $fb_shortcode['images_align'] ) : '' ) . ' popup-gallery-fb ' . esc_attr( $fts_dynamic_class_name ) . '"';
514
- if ( 'yes' === $fb_shortcode['image_stack_animation'] ) {
515
- echo 'data-masonry-options=\'{ "isFitWidth": ' . ( 'no' === $fb_shortcode['center_container'] ? 'false' : 'true' ) . ' ' . ( 'no' === $fb_shortcode['image_stack_animation'] ? ', "transitionDuration": 0' : '' ) . '}\' style="margin:auto;"';
516
- }
517
- echo '>';
518
- } elseif (
519
- // slideshow scrollHorz or carousel.
520
- ! isset( $fb_type ) && isset( $fb_shortcode['slider'] ) && 'yes' === $fb_shortcode['slider'] ) {
521
- $fts_cycle_type = isset( $fb_shortcode['scrollhorz_or_carousel'] ) ? $fb_shortcode['scrollhorz_or_carousel'] : 'scrollHorz';
522
-
523
- if ( isset( $fts_cycle_type ) && 'carousel' === $fts_cycle_type ) {
524
- $fts_cycle_slideshow = 'slideshow';
525
- } else {
526
- $fts_cycle_slideshow = 'cycle-slideshow';
527
- }
528
- echo '';
529
-
530
- // none
531
- // dots_above_feed
532
- // dots_and_arrows_above_feed
533
- // dots_and_numbers_above_feed
534
- // dots_arrows_and_numbers_above_feed
535
- // arrows_and_numbers_above_feed
536
- // arrows_above_feed
537
- // numbers_above_feed
538
- // dots_below_feed
539
- // dots_and_arrows_below_feed
540
- // dots_and_numbers_below_feed
541
- // dots_arrows_and_numbers_below_feed
542
- // arrows_and_numbers_below_feed
543
- // arrows_below_feed
544
- // numbers_below_feed.
545
- $fts_controls_bar_color = ! empty( $fb_shortcode['slider_controls_bar_color'] ) ? $fb_shortcode['slider_controls_bar_color'] : '#000';
546
- $fts_controls_text_color = ! empty( $fb_shortcode['slider_controls_text_color'] ) ? $fb_shortcode['slider_controls_text_color'] : '#ddd';
547
- if ( isset( $fb_shortcode['slider_controls_width'] ) && 'carousel' !== $fb_shortcode['scrollhorz_or_carousel'] ) {
548
- $max_width_set = isset( $fb_shortcode['image_width'] ) && '' !== $fb_shortcode['image_width'] && 'carousel' !== $fb_shortcode['scrollhorz_or_carousel'] ? $fb_shortcode['image_width'] : '100%';
549
- } else {
550
- $max_width_set = isset( $fb_shortcode['slider_controls_width'] ) && '' !== $fb_shortcode['slider_controls_width'] && 'carousel' === $fb_shortcode['scrollhorz_or_carousel'] ? $fb_shortcode['slider_controls_width'] : '100%';
551
- }
552
- if (
553
- isset( $fb_shortcode['slider_controls'] ) && 'dots_above_feed' === $fb_shortcode['slider_controls'] ||
554
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_above_feed' === $fb_shortcode['slider_controls'] ||
555
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
556
- isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
557
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
558
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_above_feed' === $fb_shortcode['slider_controls'] ||
559
- isset( $fb_shortcode['slider_controls'] ) && 'numbers_above_feed' === $fb_shortcode['slider_controls']
560
- ) {
561
-
562
- // Slider Dots Wrapper.
563
- if (
564
- isset( $fb_shortcode['slider_controls'] ) && 'dots_above_feed' === $fb_shortcode['slider_controls'] ||
565
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_above_feed' === $fb_shortcode['slider_controls'] ||
566
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
567
- isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls']
568
- ) {
569
-
570
- echo '<div class="fts-slider-icons-center fts-pager-option-dots-only-top" style="margin:auto; width:100%;max-width:' . esc_attr( $max_width_set . ';background:' . $fts_controls_bar_color . ';color:' . $fts_controls_text_color ) . '"><div class="fts-pager-option fts-custom-pager-' . esc_attr( $fts_dynamic_class_name ) . '"></div></div>';
571
- }
572
-
573
- // Slider Arrow and Numbers Wrapper.
574
- if (
575
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_above_feed' === $fb_shortcode['slider_controls'] ||
576
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
577
- isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
578
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
579
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_above_feed' === $fb_shortcode['slider_controls'] ||
580
- isset( $fb_shortcode['slider_controls'] ) && 'numbers_above_feed' === $fb_shortcode['slider_controls']
581
- ) {
582
- echo '<div class="fts-slider-center" style="margin:auto; width:100%; max-width:' . esc_attr( $max_width_set . ';background:' . $fts_controls_bar_color . ';color:' . $fts_controls_text_color ) . '">';
583
- }
584
-
585
- // Previous Arrow.
586
- if (
587
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_above_feed' === $fb_shortcode['slider_controls'] ||
588
- isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
589
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
590
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_above_feed' === $fb_shortcode['slider_controls']
591
- ) {
592
- echo '<span class="fts-prevControl-icon fts-prevControl-' . esc_attr( $fts_dynamic_class_name ) . '"></span>';
593
- }
594
- // Numbers.
595
- if (
596
- isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
597
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
598
- isset( $fb_shortcode['slider_controls'] ) && 'numbers_above_feed' === $fb_shortcode['slider_controls'] ||
599
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_above_feed' === $fb_shortcode['slider_controls']
600
- ) {
601
- echo '<span id="fts-custom-caption-' . esc_attr( $fts_dynamic_class_name ) . '" class="fts-custom-caption" ></span>';
602
- }
603
- // Next Arrow.
604
- if (
605
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_above_feed' === $fb_shortcode['slider_controls'] ||
606
- isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
607
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
608
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_above_feed' === $fb_shortcode['slider_controls']
609
- ) {
610
- echo '<span class="fts-nextControl-icon fts-nextControl-' . esc_attr( $fts_dynamic_class_name ) . '"></span>';
611
- }
612
-
613
- // Slider Arrow and Numbers Wrapper.
614
- if (
615
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_above_feed' === $fb_shortcode['slider_controls'] ||
616
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
617
- isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
618
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
619
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_above_feed' === $fb_shortcode['slider_controls'] ||
620
- isset( $fb_shortcode['slider_controls'] ) && 'numbers_above_feed' === $fb_shortcode['slider_controls']
621
- ) {
622
- echo '</div>';
623
- }
624
- }
625
-
626
- echo '<div class="popup-gallery-fb fts-fb-slideshow fts-slicker-facebook-photos fts-slicker-facebook-albums ' . esc_attr( $fts_cycle_slideshow ) . ' ' . ( isset( $fb_shortcode['video_album'] ) && $fb_shortcode['video_album'] && 'yes' === $fb_shortcode['video_album'] ? 'popup-video-gallery-fb' : '' ) . ' ' . ( isset( $fb_shortcode['images_align'] ) && $fb_shortcode['images_align'] ? ' popup-video-gallery-align-' . esc_attr( $fb_shortcode['images_align'] ) : '' ) . ' popup-gallery-fb ' . esc_attr( $fts_dynamic_class_name ) . '"
 
627
 
628
  style="margin:' . ( isset( $fb_shortcode['slider_margin'] ) && '' !== $fb_shortcode['slider_margin'] ? esc_attr( $fb_shortcode['slider_margin'] ) : 'auto' ) . ';' . ( isset( $fts_cycle_type ) && 'carousel' === $fts_cycle_type ? 'width:100%; max-width:100%; overflow:hidden;height:' . esc_attr( $fb_shortcode['image_height'] ) . ';' : 'overflow:hidden; height:' . esc_attr( $fb_shortcode['image_height'] ) . '; max-width:' . ( isset( $fb_shortcode['image_width'] ) && '' !== $fb_shortcode['image_width'] ? esc_attr( $fb_shortcode['image_width'] ) : 'auto' ) ) . ';" data-cycle-caption="#fts-custom-caption-' . esc_attr( $fts_dynamic_class_name ) . '" data-cycle-caption-template="{{slideNum}} / {{slideCount}}" data-cycle-pager=".fts-custom-pager-' . esc_attr( $fts_dynamic_class_name ) . '" data-cycle-pause-on-hover="true" data-cycle-prev=".fts-prevControl-' . esc_attr( $fts_dynamic_class_name ) . '" data-cycle-next=".fts-nextControl-' . esc_attr( $fts_dynamic_class_name ) . '" data-cycle-timeout="' . ( ! empty( $fb_shortcode['slider_timeout'] ) ? esc_attr( $fb_shortcode['slider_timeout'] ) : '0' ) . '" data-cycle-manual-speed="' . ( ! empty( $fb_shortcode['slider_speed'] ) ? esc_attr( $fb_shortcode['slider_speed'] ) : '400' ) . '" data-cycle-auto-height="false" data-cycle-slides="> div" data-cycle-fx="' . ( ! empty( $fb_shortcode['scrollhorz_or_carousel'] ) ? esc_attr( $fb_shortcode['scrollhorz_or_carousel'] ) : '' ) . '" data-cycle-carousel-visible=' . ( ! empty( $fb_shortcode['slides_visible'] ) ? esc_attr( $fb_shortcode['slides_visible'] ) : '4' ) . ' data-cycle-swipe=true data-cycle-swipe-fx=' . ( ! empty( $fb_shortcode['scrollhorz_or_carousel'] ) ? esc_attr( $fb_shortcode['scrollhorz_or_carousel'] ) : '' ) . '>';
629
- }
630
-
631
- if ( isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] ) {
632
- echo '<div class="fts-slicker-facebook-posts masonry js-masonry ' . esc_attr( $fts_mashup_media_top . $fts_mashup_show_name . $fts_mashup_show_date . $fts_mashup_show_thumbnail ) . ( 'yes' === $fb_shortcode['popup'] ? 'popup-gallery-fb-posts ' : '' ) . ( 'reviews' === $fb_shortcode['type'] ? 'fts-reviews-feed ' : '' ) . esc_attr( $fts_dynamic_class_name ) . ' " style="margin:auto;" data-masonry-options=\'{ "isFitWidth": ' . ( 'no' === $fb_shortcode['center_container'] ? 'false' : 'true' ) . ' ' . ( 'no' === $fb_shortcode['image_stack_animation'] ? ', "transitionDuration": 0' : '' ) . '}\'>';
633
- }
634
- } else {
635
- echo '<div class="fts-jal-fb-group-display fts-simple-fb-wrapper ' . esc_attr( $fts_mashup_media_top . $fts_mashup_show_name . $fts_mashup_show_date . $fts_mashup_show_thumbnail ) . ( isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ? ' popup-gallery-fb-posts ' : '' ) . ( 'reviews' === $fb_shortcode['type'] ? 'fts-reviews-feed ' : '' ) . esc_attr( $fts_dynamic_class_name ) . ' ' . ( 'auto' !== $fb_shortcode['height'] && ! empty( $fb_shortcode['height'] ) ? 'fts-fb-scrollable" style="height:' . esc_attr( $fb_shortcode['height'] ) . '"' : '"' ) . '>';
636
- }
637
- } //End ajaxing Check
638
-
639
- // *********************
640
- // Post Information
641
- // *********************
642
- $fb_load_more_text = get_option( 'fb_load_more_text' ) ? get_option( 'fb_load_more_text' ) : esc_html( 'Load More', 'feed-them-social' );
643
- $response_post_array = $this->get_post_info( $feed_data, $fb_shortcode, $access_token, $language, $fb_cache_name );
644
-
645
- // Single event info call.
646
- if ( 'events' === $fb_shortcode['type'] ) {
647
- $single_event_array_response = $this->get_event_post_info( $feed_data, $fb_shortcode, $access_token, $language );
648
- }
649
-
650
- $set_zero = 0;
651
-
652
- // echo '<br/><br/>feed array<br/><br/>';.
653
- // echo '<pre>';
654
- // print_r($feed_data );
655
- // echo '</pre>';.
656
- // THE MAIN FEED
657
- // LOOP to fix Post count!
658
- foreach ( $feed_data->data as $k => $v ) {
659
- if ( $k >= $fb_shortcode['posts'] ) {
660
- unset( $feed_data->data[ $k ] );
661
- }
662
- }
663
-
664
- // Nov. 4th. 2016 // Uncomment this to sort the dates proper if facebook is returning them out of order.
665
- // We had one case of this here for a list of posts coming from an event.
666
- // https://wordpress.org/support/topic/facebook-event-posts-not-ordered-by-date/
667
- // usort($feed_data->data, array($this, "dateSort"));
668
- // Loop for all facebook feeds.
669
- foreach ( $feed_data->data as $post_data ) {
670
-
671
- $fb_message = isset( $post_data->message ) ? $post_data->message : '';
672
- $fb_status_type = isset( $post_data->status_type ) ? $post_data->status_type : '';
673
-
674
- $fb_story = isset( $post_data->story ) ? $post_data->story : '';
675
- $fb_type = isset( $post_data->type ) ? $post_data->type : '';
676
-
677
- // This is the method to skip empty posts or posts that are simply about changing settings or other non important post types.
678
- if ( 'status' === $fb_type && empty( $fb_message ) && empty( $fb_story ) || 'event' === $fb_type || 'event' === $fb_type && false !== strpos( $fb_story, 'shared their event' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'changed the name of the event to' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'changed the privacy setting' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'an admin of the group' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'created the group' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'added an event' ) || 'event' === $fb_type && false !== strpos( $fb_story, 'added an event' ) ) {
679
- } else {
680
- // define type note also affects load more fucntion call.
681
- if ( ! $fb_type && 'album_photos' === $fb_shortcode['type'] ) {
682
- $fb_type = 'photo';
683
- }
684
- if ( ! $fb_type && 'events' === $fb_shortcode['type'] ) {
685
- $fb_type = 'events';
686
-
687
- }
688
-
689
- $post_types = new fts_facebook_feed_post_types();
690
- $single_event_array_response = isset( $single_event_array_response ) ? $single_event_array_response : '';
691
-
692
- // echo '<br/><br/>were function gets called <br/><br/>' .
693
- // print_r( $post_data );.
694
- $post_types->feed_post_types( $set_zero, $fb_type, $post_data, $fb_shortcode, $response_post_array, $single_event_array_response );
695
-
696
- }
697
-
698
- $set_zero++;
699
- }// END POST foreach
700
-
701
- if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && 'reviews' !== $fb_shortcode['type'] || is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && 'reviews' === $fb_shortcode['type'] ) {
702
- if ( ! empty( $feed_data->data ) ) {
703
- $this->fts_facebook_loadmore( $atts, $feed_data, $fb_type, $fb_shortcode, sanitize_key( $_REQUEST['fts_dynamic_name'] ) );
704
- }
705
- }
706
-
707
- echo '</div>'; // closing main div for fb photos, groups etc
708
- // only show this script if the height option is set to a number.
709
- if ( 'auto' !== $fb_shortcode['height'] && ! empty( $fb_shortcode['height'] ) ) {
710
- echo '<script>';
711
- // this makes it so the page does not scroll if you reach the end of scroll bar or go back to top'.
712
- echo 'jQuery.fn.isolatedScrollFacebookFTS = function() {';
713
- echo 'this.bind("mousewheel DOMMouseScroll", function (e) {';
714
- echo 'var delta = e.wheelDelta || (e.originalEvent && e.originalEvent.wheelDelta) || -e.detail,';
715
- echo 'bottomOverflow = this.scrollTop + jQuery(this).outerHeight() - this.scrollHeight >= 0,';
716
- echo 'topOverflow = this.scrollTop <= 0;';
717
- echo 'if ((delta < 0 && bottomOverflow) || (delta > 0 && topOverflow)) {';
718
- echo 'e.preventDefault();';
719
- echo '}';
720
- echo '});';
721
- echo 'return this;';
722
- echo '};';
723
- echo 'jQuery(".fts-fb-scrollable").isolatedScrollFacebookFTS();';
724
- echo '</script>';
725
- } //end $fb_shortcode['height'] !== 'auto' && empty($fb_shortcode['height']) == NULL
726
- // Make sure it's not ajaxing.
727
- if ( ! isset( $_GET['load_more_ajaxing'] ) ) {
728
- echo '<div class="fts-clear"></div><div id="fb-root"></div>';
729
- if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && 'reviews' !== $fb_shortcode['type'] || is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && 'reviews' === $fb_shortcode['type'] ) {
730
- if ( 'button' === $fb_shortcode['loadmore'] ) {
731
-
732
- echo '<div class="fts-fb-load-more-wrapper">';
733
- echo '<div id="loadMore_' . esc_attr( $_REQUEST['fts_dynamic_name'] ) . '" style="';
734
- if ( isset( $fb_shortcode['loadmore_btn_maxwidth'] ) && '' !== $fb_shortcode['loadmore_btn_maxwidth'] ) {
735
- echo 'max-width:' . esc_attr( $fb_shortcode['loadmore_btn_maxwidth'] ) . ';';
736
- }
737
- $loadmore_btn_margin = isset( $fb_shortcode['loadmore_btn_margin'] ) ? $fb_shortcode['loadmore_btn_margin'] : '20px';
738
- echo 'margin:' . esc_attr( $loadmore_btn_margin ) . ' auto ' . esc_attr( $loadmore_btn_margin ) . '" class="fts-fb-load-more">' . esc_html( $fb_load_more_text ) . '</div>';
739
- echo '</div>';
740
- }
741
- }
742
- }//End Check
743
-
744
- // Checks for sliders.
745
- if (
746
- isset( $fb_shortcode['slider_controls'] ) && 'dots_below_feed' === $fb_shortcode['slider_controls'] ||
747
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_below_feed' === $fb_shortcode['slider_controls'] ||
748
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
749
- isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
750
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
751
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_below_feed' === $fb_shortcode['slider_controls'] ||
752
- isset( $fb_shortcode['slider_controls'] ) && 'numbers_below_feed' === $fb_shortcode['slider_controls']
753
- ) {
754
-
755
- // Slider Dots Wrapper.
756
- if (
757
- isset( $fb_shortcode['slider_controls'] ) && 'dots_below_feed' === $fb_shortcode['slider_controls'] ||
758
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_below_feed' === $fb_shortcode['slider_controls'] ||
759
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
760
- isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls']
761
- ) {
762
- if ( isset( $fb_shortcode['slider_controls_width'] ) && 'carousel' !== $fb_shortcode['scrollhorz_or_carousel'] ) {
763
- $max_width_set = isset( $fb_shortcode['image_width'] ) && '' !== $fb_shortcode['image_width'] && 'carousel' !== $fb_shortcode['scrollhorz_or_carousel'] ? $fb_shortcode['image_width'] : '100%';
764
- } else {
765
- $max_width_set = isset( $fb_shortcode['slider_controls_width'] ) && '' !== $fb_shortcode['slider_controls_width'] && 'carousel' === $fb_shortcode['scrollhorz_or_carousel'] ? $fb_shortcode['slider_controls_width'] : '100%';
766
- }
767
-
768
- echo '<div class="fts-slider-icons-center" style="margin:auto; width:100%;max-width:' . esc_attr( $max_width_set ) . ';background:' . esc_attr( $fts_controls_bar_color ) . ';color:' . esc_attr( $fts_controls_text_color ) . '"><div class="fts-pager-option fts-custom-pager-' . esc_attr( $fts_dynamic_class_name ) . '"></div></div>';
769
- }
770
-
771
- // Slider Arrow and Numbers Wrapper.
772
- if (
773
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_below_feed' === $fb_shortcode['slider_controls'] ||
774
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
775
- isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
776
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
777
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_below_feed' === $fb_shortcode['slider_controls'] ||
778
- isset( $fb_shortcode['slider_controls'] ) && 'numbers_below_feed' === $fb_shortcode['slider_controls']
779
- ) {
780
- echo '<div class="fts-slider-center" style="margin:auto; width:100%; max-width:' . esc_attr( $max_width_set ) . ';background:' . esc_attr( $fts_controls_bar_color ) . ';color:' . esc_attr( $fts_controls_text_color ) . '">';
781
- }
782
-
783
- // Previous Arrow.
784
- if (
785
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_below_feed' === $fb_shortcode['slider_controls'] ||
786
- isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
787
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
788
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_below_feed' === $fb_shortcode['slider_controls']
789
- ) {
790
- echo '<span class="fts-prevControl-icon fts-prevControl-' . esc_attr( $fts_dynamic_class_name ) . '"></span>';
791
- }
792
- // Numbers.
793
- if (
794
- isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
795
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
796
- isset( $fb_shortcode['slider_controls'] ) && 'numbers_below_feed' === $fb_shortcode['slider_controls'] ||
797
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_below_feed' === $fb_shortcode['slider_controls']
798
- ) {
799
- echo '<span id="fts-custom-caption-' . esc_attr( $fts_dynamic_class_name ) . '" class="fts-custom-caption" ></span>';
800
- }
801
- // Next Arrow.
802
- if (
803
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_below_feed' === $fb_shortcode['slider_controls'] ||
804
- isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
805
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
806
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_below_feed' === $fb_shortcode['slider_controls']
807
- ) {
808
- echo '<span class="fts-nextControl-icon fts-nextControl-' . esc_attr( $fts_dynamic_class_name ) . '"></span>';
809
- }
810
-
811
- // Slider Arrow and Numbers Wrapper.
812
- if (
813
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_below_feed' === $fb_shortcode['slider_controls'] ||
814
- isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
815
- isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
816
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
817
- isset( $fb_shortcode['slider_controls'] ) && 'arrows_below_feed' === $fb_shortcode['slider_controls'] ||
818
- isset( $fb_shortcode['slider_controls'] ) && 'numbers_below_feed' === $fb_shortcode['slider_controls']
819
- ) {
820
- echo '</div>';
821
- }
822
- }
823
-
824
- unset( $_REQUEST['next_url'] );
825
-
826
- // ******************
827
- // SOCIAL BUTTON
828
- // ******************
829
- if ( ! $fts_count_ids >= 1 ) {
830
- $this->fb_social_btn_placement( $fb_shortcode, $access_token, 'fb-like-below' );
831
- }
832
-
833
- return ob_get_clean();
834
- }
835
-
836
- /**
837
- * Get FTS Dnamic Class Name
838
- *
839
- * @return string
840
- * @since 1.9.6
841
- */
842
- public function get_fts_dynamic_class_name() {
843
- $fts_dynamic_class_name = '';
844
- if ( isset( $_REQUEST['fts_dynamic_name'] ) ) {
845
- $fts_dynamic_class_name = 'feed_dynamic_class' . sanitize_key( $_REQUEST['fts_dynamic_name'] );
846
- }
847
- return $fts_dynamic_class_name;
848
- }
849
-
850
- /**
851
- * FTS Facebook Location
852
- *
853
- * Facebook Post Location.
854
- *
855
- * @param null $fb_type What kind of facebook feed it is.
856
- * @param string $location The location of the photo or video.
857
- * @since 1.9.6
858
- */
859
- public function fts_facebook_location( $fb_type = null, $location ) {
860
- switch ( $fb_type ) {
861
- case 'app':
862
- case 'cover':
863
- case 'profile':
864
- case 'mobile':
865
- case 'wall':
866
- case 'normal':
867
- case 'album':
868
- echo '<div class="fts-fb-location">' . esc_html( $location ) . '</div>';
869
- }
870
- }
871
-
872
- /**
873
- * FTS Facebook Post Photo
874
- *
875
- * @param string $fb_link The link to post.
876
- * @param string $fb_shortcode The shortcode.
877
- * @param string $photo_from Who it's from.
878
- * @param string $photo_source The source url.
879
- * @since 1.9.6
880
- */
881
- public function fts_facebook_post_photo( $fb_link, $fb_shortcode, $photo_from, $photo_source ) {
882
- if ( 'album_photos' === $fb_shortcode['type'] || 'albums' === $fb_shortcode['type'] ) {
883
- echo '<a href="' . esc_url( $fb_link ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-picture album-photo-fts" style="width:' . esc_attr( $fb_shortcode['image_width'] . ';height:' . $fb_shortcode['image_height'] ) . ';';
884
- echo 'background-image:url(' . esc_url( $photo_source ) . ');">';
885
- echo '</a>';
886
- } else {
887
- $fb_shortcode_popup = isset( $fb_shortcode['popup'] ) ? $fb_shortcode['popup'] : '';
888
- if ( 'yes' === $fb_shortcode_popup && 'javascript:;' !== $fb_link ) {
889
- echo '<a href="' . esc_url( $photo_source ) . '" target="_blank" rel="noreferrer" class="fts-facebook-link-target fts-jal-fb-picture fts-fb-large-photo"><img border="0" alt="' . esc_html( $photo_from ) . '" src="' . esc_url( $photo_source ) . '"/></a>';
890
-
891
- } else {
892
- echo '<a href="' . esc_url( $fb_link ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-picture"><img border="0" alt="' . esc_html( $photo_from ) . '" src="' . esc_url( $photo_source ) . '"/></a>';
893
- }
894
- }
895
- }
896
-
897
- /**
898
- * FTS Facebook Post Name
899
- *
900
- * @param string $fb_link The post link.
901
- * @param string $fb_name The facebook name.
902
- * @param string $fb_type The type of feed.
903
- * @param null $fb_post_id The facebook post ID.
904
- * @since 1.9.6
905
- */
906
- public function fts_facebook_post_name( $fb_link, $fb_name, $fb_type, $fb_post_id = null ) {
907
- switch ( $fb_type ) {
908
- case 'video':
909
- echo '<a href="' . esc_url( $fb_link ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-name fb-id' . esc_attr( $fb_post_id ) . '">' . wp_kses(
910
- $this->fts_facebook_tag_filter( $fb_name ),
911
- array(
912
- 'a' => array(
913
- 'href' => array(),
914
- 'title' => array(),
915
- ),
916
- 'br' => array(),
917
- 'em' => array(),
918
- 'strong' => array(),
919
- 'small' => array(),
920
- )
921
- ) . '</a>';
922
- break;
923
- default:
924
- $fb_name = $this->fts_facebook_tag_filter( $fb_name );
925
- echo '<a href="' . esc_url( $fb_link ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-name">' . wp_kses(
926
- $this->fts_facebook_tag_filter( $fb_name ),
927
- array(
928
- 'a' => array(
929
- 'href' => array(),
930
- 'title' => array(),
931
- ),
932
- 'br' => array(),
933
- 'em' => array(),
934
- 'strong' => array(),
935
- 'small' => array(),
936
- )
937
- ) . '</a>';
938
- break;
939
- }
940
- }
941
-
942
- /**
943
- * FTS Facebook Post Description
944
- *
945
- * @param string $fb_description The post description.
946
- * @param string $fb_shortcode The shortcode.
947
- * @param string $fb_type The type of feed.
948
- * @param null $fb_post_id The post ID.
949
- * @param null $fb_by The post by.
950
- * @since 1.9.6
951
- */
952
- public function fts_facebook_post_desc( $fb_description, $fb_shortcode, $fb_type, $fb_post_id = null, $fb_by = null ) {
953
- $trunacate_words = new \FeedThemSocialTruncateHTML();
954
-
955
- $fb_description = $this->fts_facebook_tag_filter( $fb_description );
956
- $more = isset( $more ) ? $more : '...';
957
-
958
- switch ( $fb_type ) {
959
- case 'video':
960
- echo '<div class="fts-jal-fb-description fb-id' . esc_attr( $fb_post_id ) . '">' . wp_kses(
961
- nl2br( $fb_description ),
962
- array(
963
- 'a' => array(
964
- 'href' => array(),
965
- 'title' => array(),
966
- ),
967
- 'br' => array(),
968
- 'em' => array(),
969
- 'strong' => array(),
970
- 'small' => array(),
971
- )
972
- ) . '</div>';
973
- break;
974
- case 'photo':
975
- if ( 'album_photos' === $fb_shortcode['type'] ) {
976
- if ( array_key_exists( 'words', $fb_shortcode ) ) {
977
- $trimmed_content = $trunacate_words->fts_custom_trim_words( $fb_description, $fb_shortcode['words'], $more );
978
- echo '<div class="fts-jal-fb-description fts-non-popup-text">' . wp_kses(
979
- nl2br( $trimmed_content ),
980
- array(
981
- 'a' => array(
982
- 'href' => array(),
983
- 'title' => array(),
984
- ),
985
- 'br' => array(),
986
- 'em' => array(),
987
- 'strong' => array(),
988
- 'small' => array(),
989
- )
990
- ) . '</div>';
991
- // Here we display the full description in the popup.
992
- if ( 'yes' === $fb_shortcode['popup'] || 'yes' === $fb_shortcode['video_album'] ) {
993
- echo '<div class="fts-jal-fb-description fts-jal-fb-description-popup" style="display: none;">' . wp_kses(
994
- nl2br( $fb_description ),
995
- array(
996
- 'a' => array(
997
- 'href' => array(),
998
- 'title' => array(),
999
- ),
1000
- 'br' => array(),
1001
- 'em' => array(),
1002
- 'strong' => array(),
1003
- 'small' => array(),
1004
- )
1005
- ) . '</div>';
1006
- }
1007
- } elseif ( isset( $fb_shortcode['words'] ) && '0' !== $fb_shortcode['words'] ) {
1008
- echo '<div class="fts-jal-fb-description">' . wp_kses(
1009
- nl2br( $fb_description ),
1010
- array(
1011
- 'a' => array(
1012
- 'href' => array(),
1013
- 'title' => array(),
1014
- ),
1015
- 'br' => array(),
1016
- 'em' => array(),
1017
- 'strong' => array(),
1018
- 'small' => array(),
1019
- )
1020
- ) . '</div>';
1021
- }
1022
- }
1023
- break;
1024
- case 'albums':
1025
- if ( 'albums' === $fb_shortcode['type'] ) {
1026
- if ( array_key_exists( 'words', $fb_shortcode ) ) {
1027
- $trimmed_content = $trunacate_words->fts_custom_trim_words( $fb_description, $fb_shortcode['words'], $more );
1028
- echo '<div class="fts-jal-fb-description">' . wp_kses(
1029
- nl2br( $trimmed_content ),
1030
- array(
1031
- 'a' => array(
1032
- 'href' => array(),
1033
- 'title' => array(),
1034
- ),
1035
- 'br' => array(),
1036
- 'em' => array(),
1037
- 'strong' => array(),
1038
- 'small' => array(),
1039
- )
1040
- ) . '</div>';
1041
- } else {
1042
- echo '<div class="fts-jal-fb-description">' . wp_kses(
1043
- nl2br( $fb_description ),
1044
- array(
1045
- 'a' => array(
1046
- 'href' => array(),
1047
- 'title' => array(),
1048
- ),
1049
- 'br' => array(),
1050
- 'em' => array(),
1051
- 'strong' => array(),
1052
- 'small' => array(),
1053
- )
1054
- ) . '</div>';
1055
- }
1056
- } else {
1057
- // Do for Default feeds or the video gallery feed.
1058
- if ( isset( $fb_shortcode['words'] ) && '0' !== $fb_shortcode['words'] ) {
1059
- if ( is_array( $fb_shortcode ) && array_key_exists( 'words', $fb_shortcode ) && '0' !== $fb_shortcode['words'] ) {
1060
- $trimmed_content = $trunacate_words->fts_custom_trim_words( $fb_description, $fb_shortcode['words'], $more );
1061
- echo '<div class="fts-jal-fb-description">' . wp_kses(
1062
- $trimmed_content,
1063
- array(
1064
- 'a' => array(
1065
- 'href' => array(),
1066
- 'title' => array(),
1067
- 'target' => array(),
1068
- 'rel' => array(),
1069
- ),
1070
- 'br' => array(),
1071
- 'em' => array(),
1072
- 'strong' => array(),
1073
- 'small' => array(),
1074
- )
1075
- ) . '</div>';
1076
- } else {
1077
- echo '<div class="fts-jal-fb-description">';
1078
- echo wp_kses(
1079
- nl2br( $fb_description ),
1080
- array(
1081
- 'a' => array(
1082
- 'href' => array(),
1083
- 'title' => array(),
1084
- 'target' => array(),
1085
- 'rel' => array(),
1086
- ),
1087
- 'br' => array(),
1088
- 'em' => array(),
1089
- 'strong' => array(),
1090
- 'small' => array(),
1091
- )
1092
- );
1093
- echo '</div>';
1094
- }
1095
- if ( ! empty( $fb_link ) ) {
1096
- echo '<div>By: <a href="' . esc_url( $fb_link ) . '" target="_blank" rel="noreferrer">' . esc_html( $fb_by ) . '<a/></div>';
1097
- }
1098
- }
1099
- }
1100
- break;
1101
- default:
1102
- include_once ABSPATH . 'wp-admin/includes/plugin.php';
1103
- if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) || is_plugin_active( 'feed-them-social-combined-streams/feed-them-social-combined-streams.php' ) ) {
1104
- // here we trim the words for the links description text... for the premium version. The $fb_shortcode['words'] string actually comes from the javascript.
1105
- if ( is_array( $fb_shortcode ) && array_key_exists( 'words', $fb_shortcode ) && ! empty( $fb_shortcode['words'] ) ) {
1106
-
1107
- $trimmed_content = $trunacate_words->fts_custom_trim_words( $fb_description, $fb_shortcode['words'], $more );
1108
- echo '<div class="jal-fb-description">' . wp_kses(
1109
- nl2br( $trimmed_content ),
1110
- array(
1111
- 'a' => array(
1112
- 'href' => array(),
1113
- 'title' => array(),
1114
- 'target' => array(),
1115
- 'rel' => array(),
1116
- ),
1117
- 'br' => array(),
1118
- 'em' => array(),
1119
- 'strong' => array(),
1120
- 'small' => array(),
1121
- )
1122
- ) . '</div>';
1123
- } elseif ( is_array( $fb_shortcode ) && array_key_exists( 'words', $fb_shortcode ) && '0' !== $fb_shortcode['words'] ) {
1124
- echo '<div class="jal-fb-description">' . wp_kses(
1125
- nl2br( $fb_description ),
1126
- array(
1127
- 'a' => array(
1128
- 'href' => array(),
1129
- 'title' => array(),
1130
- 'target' => array(),
1131
- 'rel' => array(),
1132
- ),
1133
- 'br' => array(),
1134
- 'em' => array(),
1135
- 'strong' => array(),
1136
- 'small' => array(),
1137
- )
1138
- ) . '</div>';
1139
- }
1140
- } else {
1141
- // if the premium plugin is not active we will just show the regular full description.
1142
- echo '<div class="jal-fb-description">' . wp_kses(
1143
- nl2br( $fb_description ),
1144
- array(
1145
- 'a' => array(
1146
- 'href' => array(),
1147
- 'title' => array(),
1148
- 'target' => array(),
1149
- 'rel' => array(),
1150
- ),
1151
- 'br' => array(),
1152
- 'em' => array(),
1153
- 'strong' => array(),
1154
- 'small' => array(),
1155
- )
1156
- ) . '</div>';
1157
- }
1158
- }
1159
- }
1160
-
1161
- /**
1162
- * FTS Facebook Post Caption
1163
- *
1164
- * @param string $fb_caption The post caption.
1165
- * @param string $fb_shortcode The shortcode.
1166
- * @param string $fb_type The type of feed.
1167
- * @param null $fb_post_id The post ID.
1168
- * @since 1.9.6
1169
- */
1170
- public function fts_facebook_post_cap( $fb_caption, $fb_shortcode, $fb_type, $fb_post_id = null ) {
1171
- $trunacate_words = new \FeedThemSocialTruncateHTML();
1172
- switch ( $fb_type ) {
1173
- case 'video':
1174
- $fb_caption = $this->fts_facebook_tag_filter( str_replace( 'www.', '', $fb_caption ) );
1175
- echo '<div class="fts-jal-fb-caption fb-id' . esc_attr( $fb_post_id ) . '">' . wp_kses(
1176
- $fb_caption,
1177
- array(
1178
- 'a' => array(
1179
- 'href' => array(),
1180
- 'title' => array(),
1181
- ),
1182
- 'br' => array(),
1183
- 'em' => array(),
1184
- 'strong' => array(),
1185
- 'small' => array(),
1186
- )
1187
- ) . '</div>';
1188
- break;
1189
- default:
1190
- include_once ABSPATH . 'wp-admin/includes/plugin.php';
1191
- if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) || is_plugin_active( 'feed-them-social-combined-streams/feed-them-social-combined-streams.php' ) ) {
1192
- // here we trim the words for the links description text... for the premium version. The $fb_shortcode['words'] string actually comes from the javascript.
1193
- if ( array_key_exists( 'words', $fb_shortcode ) ) {
1194
- $more = isset( $more ) ? $more : '';
1195
- $trimmed_content = $trunacate_words->fts_custom_trim_words( $fb_caption, $fb_shortcode['words'], $more );
1196
- echo '<div class="jal-fb-caption">' . wp_kses(
1197
- $trimmed_content,
1198
- array(
1199
- 'a' => array(
1200
- 'href' => array(),
1201
- 'title' => array(),
1202
- ),
1203
- 'br' => array(),
1204
- 'em' => array(),
1205
- 'strong' => array(),
1206
- 'small' => array(),
1207
- )
1208
- ) . '</div>';
1209
- } else {
1210
- $fb_caption = $this->fts_facebook_tag_filter( $fb_caption );
1211
- echo '<div class="jal-fb-caption">' . wp_kses(
1212
- nl2br( $fb_caption ),
1213
- array(
1214
- 'a' => array(
1215
- 'href' => array(),
1216
- 'title' => array(),
1217
- ),
1218
- 'br' => array(),
1219
- 'em' => array(),
1220
- 'strong' => array(),
1221
- 'small' => array(),
1222
- )
1223
- ) . '</div>';
1224
- }
1225
- } else {
1226
- // if the premium plugin is not active we will just show the regular full description.
1227
- $fb_caption = $this->fts_facebook_tag_filter( $fb_caption );
1228
- echo '<div class="jal-fb-caption">' . wp_kses(
1229
- nl2br( $fb_caption ),
1230
- array(
1231
- 'a' => array(
1232
- 'href' => array(),
1233
- 'title' => array(),
1234
- ),
1235
- 'br' => array(),
1236
- 'em' => array(),
1237
- 'strong' => array(),
1238
- 'small' => array(),
1239
- )
1240
- ) . '</div>';
1241
- }
1242
- }
1243
- }
1244
-
1245
- /**
1246
- * Get Likes Shares Comments
1247
- *
1248
- * Get the total count for all.
1249
- *
1250
- * @param string $response_post_array The array from facebook.
1251
- * @param string $post_data_key The post data Key.
1252
- * @param string $fb_post_share_count The post Share Count.
1253
- * @return array
1254
- * @since 1.9.6
1255
- */
1256
- public function get_likes_shares_comments( $response_post_array, $post_data_key, $fb_post_share_count ) {
1257
- $lsc_array = array();
1258
- // Get Likes & Comments.
1259
- if ( $response_post_array ) {
1260
- if ( isset( $response_post_array[ $post_data_key . '_likes' ] ) ) {
1261
- $like_count_data = json_decode( $response_post_array[ $post_data_key . '_likes' ] );
1262
-
1263
- // Like Count.
1264
- if ( ! empty( $like_count_data->summary->total_count ) ) {
1265
- $fb_post_like_count = $like_count_data->summary->total_count;
1266
- } else {
1267
- $fb_post_like_count = 0;
1268
- }
1269
- if ( 0 === $fb_post_like_count ) {
1270
- $lsc_array['likes'] = '';
1271
- }
1272
- if ( 1 === $fb_post_like_count ) {
1273
- $lsc_array['likes'] = "<i class='icon-thumbs-up'></i> 1";
1274
- }
1275
- if ( $fb_post_like_count > '1' ) {
1276
- $lsc_array['likes'] = "<i class='icon-thumbs-up'></i> " . esc_html( $fb_post_like_count );
1277
- }
1278
- }
1279
- if ( isset( $response_post_array[ $post_data_key . '_comments' ] ) ) {
1280
- $comment_count_data = json_decode( $response_post_array[ $post_data_key . '_comments' ] );
1281
-
1282
- if ( ! empty( $comment_count_data->summary->total_count ) ) {
1283
- $fb_post_comments_count = $comment_count_data->summary->total_count;
1284
- } else {
1285
- $fb_post_comments_count = 0;
1286
- }
1287
- if ( 0 === $fb_post_comments_count ) {
1288
- $lsc_array['comments'] = '';
1289
- }
1290
- if ( 1 === $fb_post_comments_count ) {
1291
- $lsc_array['comments'] = "<i class='icon-comments'></i> 1";
1292
- $lsc_array['comments_thread'] = $comment_count_data;
1293
-
1294
- }
1295
- if ( $fb_post_comments_count > '1' ) {
1296
- $lsc_array['comments'] = "<i class='icon-comments'></i> " . $fb_post_comments_count;
1297
- $lsc_array['comments_thread'] = $comment_count_data;
1298
- }
1299
- }
1300
- }
1301
- // Shares Count.
1302
- if ( 0 === $fb_post_share_count || ! $fb_post_share_count ) {
1303
- $lsc_array['shares'] = '';
1304
- }
1305
- if ( 1 === $fb_post_share_count ) {
1306
- $lsc_array['shares'] = "<i class='icon-file'></i> 1";
1307
- }
1308
- if ( $fb_post_share_count > '1' ) {
1309
- $lsc_array['shares'] = "<i class='icon-file'></i> " . $fb_post_share_count;
1310
- }
1311
- return $lsc_array;
1312
- }
1313
-
1314
-
1315
- /**
1316
- * FTS Facebook Post See More
1317
- *
1318
- * Generate See More Button.
1319
- *
1320
- * @param string $fb_link The facebook link.
1321
- * @param string $lcs_array The lcs array.
1322
- * @param string $fb_type The type of feed.
1323
- * @param null $fb_post_id The post id.
1324
- * @param string $fb_shortcode The shortcode.
1325
- * @param null $fb_post_user_id The user id.
1326
- * @param null $fb_post_single_id The single post id.
1327
- * @param null $single_event_id The event id.
1328
- * @param string $post_data The post data.
1329
- * @since 1.9.6
1330
- */
1331
- public function fts_facebook_post_see_more( $fb_link, $lcs_array, $fb_type, $fb_post_id = null, $fb_shortcode, $fb_post_user_id = null, $fb_post_single_id = null, $single_event_id = null, $post_data ) {
1332
-
1333
- $description = isset( $post_data->message ) ? $post_data->message : '';
1334
- // SHOW THE FB FEED PRINT_R
1335
- // echo'<pre>';.
1336
- // print_r();.
1337
- // echo'</pre>';.
1338
- $view_on_facebook = get_option( 'fb_view_on_fb_fts' ) ? get_option( 'fb_view_on_fb_fts' ) : __( 'View on Facebook', 'feed-them-social' );
1339
- $share_this = new feed_them_social_functions();
1340
- switch ( $fb_type ) {
1341
- case 'events':
1342
- $single_event_id = 'https://www.facebook.com/events/' . $single_event_id;
1343
- echo '<div class="fts-likes-shares-etc-wrap">';
1344
- echo $share_this->fts_share_option( $single_event_id, $description );
1345
- echo '<a href="' . esc_attr( $single_event_id ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-see-more">' . esc_html( $view_on_facebook ) . '</a></div>';
1346
- break;
1347
- case 'photo':
1348
- if ( ! empty( $fb_link ) ) {
1349
- echo '<div class="fts-likes-shares-etc-wrap">';
1350
- echo $share_this->fts_share_option( $fb_link, $description );
1351
- echo '<a href="' . esc_url( $fb_link ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-see-more">';
1352
- } else {
1353
- // exception for videos.
1354
- $single_video_id = 'https://www.facebook.com/' . $fb_post_id;
1355
- echo '<div class="fts-likes-shares-etc-wrap">';
1356
- echo $share_this->fts_share_option( $single_video_id, $description );
1357
- echo '<a href="' . esc_url( $single_video_id ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-see-more">';
1358
- }
1359
- if ( 'album_photos' === $fb_shortcode['type'] && 'yes' === $fb_shortcode['hide_date_likes_comments'] ) {
1360
-
1361
- echo '<div class="hide-date-likes-comments-etc">' . wp_kses(
1362
- $lcs_array['likes'] . ' ' . $lcs_array['comments'] . ' ' . $lcs_array['shares'],
1363
- array(
1364
- 'a' => array(
1365
- 'href' => array(),
1366
- 'title' => array(),
1367
- ),
1368
- 'i' => array(
1369
- 'class' => array(),
1370
- ),
1371
- )
1372
- ) . ' &nbsp;&nbsp;</div>';
1373
- } else {
1374
-
1375
- echo '' . wp_kses(
1376
- $lcs_array['likes'] . ' ' . $lcs_array['comments'] . ' ' . $lcs_array['shares'],
1377
- array(
1378
- 'a' => array(
1379
- 'href' => array(),
1380
- 'title' => array(),
1381
- ),
1382
- 'i' => array(
1383
- 'class' => array(),
1384
- ),
1385
- )
1386
- ) . ' &nbsp;&nbsp;';
1387
- }
1388
- echo '&nbsp;' . esc_html( $view_on_facebook ) . '</a></div>';
1389
- break;
1390
- case 'app':
1391
- case 'cover':
1392
- case 'profile':
1393
- case 'mobile':
1394
- case 'wall':
1395
- case 'normal':
1396
- case 'albums':
1397
- $url_parsed = parse_url( $fb_link, PHP_URL_QUERY );
1398
- $params = parse_str( $url_parsed, $params );
1399
- $new_album_url = str_replace( 'album.php?fbid=' . $params['fbid'] . '&id=' . $params['id'] . '&aid=' . $params['aid'], 'media/set/?set=a.' . $params['fbid'] . '.' . $params['aid'] . '.' . $params['id'], $fb_link );
1400
-
1401
- echo '<div class="fts-likes-shares-etc-wrap">';
1402
- echo $share_this->fts_share_option( $new_album_url, $description );
1403
- echo '<a href="' . esc_url( $new_album_url ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-see-more">';
1404
- if ( 'albums' === $fb_shortcode['type'] && 'yes' === $fb_shortcode['hide_date_likes_comments'] ) {
1405
- } else {
1406
-
1407
- echo '' . wp_kses(
1408
- $lcs_array['likes'] . ' ' . $lcs_array['comments'],
1409
- array(
1410
- 'a' => array(
1411
- 'href' => array(),
1412
- 'title' => array(),
1413
- ),
1414
- 'i' => array(
1415
- 'class' => array(),
1416
- ),
1417
- )
1418
- ) . ' &nbsp;&nbsp;';
1419
- }
1420
- echo '&nbsp;' . esc_html( $view_on_facebook ) . '</a></div>';
1421
- break;
1422
- default:
1423
- if ( 'yes' !== get_option( 'fb_reviews_remove_see_reviews_link' ) ) {
1424
- if ( 'reviews' === $fb_shortcode['type'] && is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) ) {
1425
- $fb_reviews_see_more_reviews_language = get_option( 'fb_reviews_see_more_reviews_language' ) ? get_option( 'fb_reviews_see_more_reviews_language' ) : 'See More Reviews';
1426
-
1427
- $hide_see_more = isset( $fb_shortcode['hide_see_more_reviews_link'] ) ? $fb_shortcode['hide_see_more_reviews_link'] : 'yes';
1428
- if ( 'yes' !== $hide_see_more ) {
1429
- echo ' <a href="' . esc_url( 'https://www.facebook.com/' . $fb_shortcode['id'] . '/reviews' ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-see-more">' . esc_html( $fb_reviews_see_more_reviews_language, 'feed-them-social' ) . '</a>';
1430
- }
1431
- } else {
1432
- $post_single_id = 'https://www.facebook.com/' . $fb_post_user_id . '/posts/' . $fb_post_single_id;
1433
- echo '<div class="fts-likes-shares-etc-wrap">';
1434
- echo $share_this->fts_share_option( $post_single_id, $description );
1435
- echo '<a href="' . esc_url( $post_single_id ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-see-more">';
1436
-
1437
- echo '' . wp_kses(
1438
- $lcs_array['likes'] . ' ' . $lcs_array['comments'],
1439
- array(
1440
- 'a' => array(
1441
- 'href' => array(),
1442
- 'title' => array(),
1443
- ),
1444
- 'i' => array(
1445
- 'class' => array(),
1446
- ),
1447
- )
1448
- ) . ' &nbsp;&nbsp;&nbsp;' . esc_html( $view_on_facebook ) . '</a></div>';
1449
- }
1450
- }
1451
- break;
1452
- }
1453
- }
1454
-
1455
- /**
1456
- * Get Access Token
1457
- *
1458
- * @return mixed
1459
- * @since 1.9.6
1460
- */
1461
- public function get_access_token() {
1462
- // The API Access Token.
1463
- // $custom_access_token = get_option('fts_facebook_custom_api_token');
1464
- // if (!empty($custom_access_token)) {
1465
- // return $access_token;
1466
- // } else {
1467
- // Randomizer
1468
- // $values = array(
1469
- // '431287540548931|4A23YYIFqhd-gpz_E4Fy6U_Seo0',
1470
- // '1748446362151826|epVUmLiKT8QhLN63iRvvXXHwxqk',
1471
- // '1875381106044241|KmWz3mtzGye0M5HTdX0SK7rqpIU',
1472
- // '754106341419549|AMruxCJ_ly8825VXeLhBKo_kOfs',
1473
- // '438563519819257|1GJ8GLl1AQ7ZTvXV_Xpok_QpH6s',
1474
- // '753693994788276|xm_PXoNRWW8WPQdcQArRpBgWn5Q',
1475
- // '644818402385988|sABEvG0QiOaJRlNLC2NphfQLlfg',
1476
- // '292500071162951|9MA-kzWVs6HTEybpdxKjgF_gqeo',
1477
- // '263710677420086|Jpui2CFig7RbtdHaHPN_fiEa77U',
1478
- // '1850081601881384|u2JcPCn7TH40MY5BwC-i4PMHGm8',
1479
- // );
1480
- // $access_token = $values[array_rand($values, 1)];.
1481
- return get_option( 'fts_facebook_custom_api_token' );
1482
- // }
1483
- }
1484
-
1485
- /**
1486
- * Get View Link
1487
- *
1488
- * @param string $fb_shortcode The facebook feed shortcode.
1489
- * @return string
1490
- * @since 1.9.6
1491
- */
1492
- public function get_view_link( $fb_shortcode ) {
1493
- switch ( $fb_shortcode['type'] ) {
1494
- case 'group':
1495
- $fts_view_fb_link = 'https://www.facebook.com/groups/' . $fb_shortcode['id'] . '/';
1496
- break;
1497
- case 'page':
1498
- $fts_view_fb_link = 'https://www.facebook.com/' . $fb_shortcode['id'] . '/';
1499
- break;
1500
- case 'event':
1501
- $fts_view_fb_link = 'https://www.facebook.com/events/' . $fb_shortcode['id'] . '/';
1502
- break;
1503
- case 'events':
1504
- $fts_view_fb_link = 'https://www.facebook.com/' . $fb_shortcode['id'] . '/events/';
1505
- break;
1506
- case 'albums':
1507
- $fts_view_fb_link = 'https://www.facebook.com/' . $fb_shortcode['id'] . '/photos_stream?tab=photos_albums';
1508
- break;
1509
- // album photos and videos album.
1510
- case 'album_photos':
1511
- $fts_view_fb_link = isset( $fb_shortcode['video_album'] ) && 'yes' === $fb_shortcode['video_album'] ? 'https://www.facebook.com/' . $fb_shortcode['id'] . '/videos/' : 'https://www.facebook.com/' . $fb_shortcode['id'] . '/photos_stream/';
1512
- break;
1513
- case 'hashtag':
1514
- $fts_view_fb_link = 'https://www.facebook.com/hashtag/' . $fb_shortcode['id'] . '/';
1515
- break;
1516
- case 'reviews':
1517
- $fts_view_fb_link = 'https://www.facebook.com/' . $fb_shortcode['id'] . '/reviews/';
1518
- break;
1519
- }
1520
- $fts_view_fb_link = isset( $fts_view_fb_link ) ? $fts_view_fb_link : '';
1521
- return $fts_view_fb_link;
1522
- }
1523
-
1524
- /**
1525
- * Get FB Cache Name
1526
- *
1527
- * @param string $fb_shortcode The facebook feed shortcode.
1528
- * @return string
1529
- * @since 1.9.6
1530
- */
1531
- public function get_fb_cache_name( $fb_shortcode ) {
1532
- // URL to get page info.
1533
- $r_count = substr_count( $fb_shortcode['id'], ',' );
1534
-
1535
- if ( $r_count >= 1 ) {
1536
- $result = preg_replace( '/[ ,]+/', '-', trim( $fb_shortcode['id'] ) );
1537
- $fb_shortcode['id'] = $result;
1538
- }
1539
-
1540
- switch ( $fb_shortcode['type'] ) {
1541
- case 'album_photos':
1542
- $fb_data_cache_name = 'fb_' . $fb_shortcode['type'] . '_' . $fb_shortcode['id'] . '_' . $fb_shortcode['album_id'] . '_num' . $fb_shortcode['posts'] . '';
1543
- break;
1544
- default:
1545
- $fb_data_cache_name = 'fb_' . $fb_shortcode['type'] . '_' . $fb_shortcode['id'] . '_num' . $fb_shortcode['posts'] . '';
1546
- break;
1547
- }
1548
- return $fb_data_cache_name;
1549
- }
1550
-
1551
- /**
1552
- * Get Language
1553
- *
1554
- * @return string
1555
- * @since 1.9.6
1556
- */
1557
- public function get_language() {
1558
- // this check is in place because we used this option and it failed for many people because we use wp get contents instead of curl.
1559
- // this can be removed in a future update and just keep the $language_option = get_option('fb_language', 'en_US');.
1560
- $language_option_check = get_option( 'fb_language' );
1561
- if ( isset( $language_option_check ) && 'Please Select Option' !== $language_option_check ) {
1562
- $language_option = get_option( 'fb_language', 'en_US' );
1563
- } else {
1564
- $language_option = 'en_US';
1565
- }
1566
- return ! empty( $language_option ) ? '&locale=' . $language_option : '';
1567
- }
1568
-
1569
- /**
1570
- * Get Facebook Overall Rating Response
1571
- *
1572
- * @param string $fb_shortcode The facebook feed shortcode.
1573
- * @param string $fb_cache_name The Cache Name.
1574
- * @param string $access_token The Access Token.
1575
- * @since 2.1.3
1576
- */
1577
- public function get_facebook_overall_rating_response( $fb_shortcode, $fb_cache_name, $access_token ) {
1578
-
1579
- // $mulit_data_rating = $this->fts_get_feed_json($mulit_data_rating);.
1580
- // Error Check
1581
- // $feed_data_rating_overall = json_decode($mulit_data['rating_data']);.
1582
- $fb_reviews_overall_rating_of_5_stars_text = get_option( 'fb_reviews_overall_rating_of_5_stars_text' );
1583
- $fb_reviews_overall_rating_of_5_stars_text = ! empty( $fb_reviews_overall_rating_of_5_stars_text ) ? ' ' . $fb_reviews_overall_rating_of_5_stars_text : ' of 5 stars';
1584
- $fb_reviews_overall_rating_reviews_text = get_option( 'fb_reviews_overall_rating_reviews_text' );
1585
- $fb_reviews_overall_rating_reviews_text = ! empty( $fb_reviews_overall_rating_reviews_text ) ? ' ' . $fb_reviews_overall_rating_reviews_text : ' reviews';
1586
- $fb_reviews_overall_rating_background_border_hide = get_option( 'fb_reviews_overall_rating_background_border_hide' );
1587
- $fb_reviews_overall_rating_background_border_hide = ! empty( $fb_reviews_overall_rating_background_border_hide ) && 'yes' === $fb_reviews_overall_rating_background_border_hide ? ' fts-review-details-master-wrap-no-background-or-border' : '';
1588
-
1589
- echo '<div class="fts-review-details-master-wrap' . esc_attr( $fb_reviews_overall_rating_background_border_hide ) . '"><i class="fts-review-star">' . esc_html( $feed_data_rating_overall->overall_star_rating ) . ' &#9733;</i>';
1590
- echo '<div class="fts-review-details-wrap" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"><div class="fts-review-details"><span itemprop="ratingValue">' . esc_html( $feed_data_rating_overall->overall_star_rating ) . '</span>' . esc_html( $fb_reviews_overall_rating_of_5_stars_text ) . '</div>';
1591
- echo '<div class="fts-review-details-count"><span itemprop="reviewCount">' . esc_html( $feed_data_rating_overall->rating_count ) . '</span>' . esc_html( $fb_reviews_overall_rating_reviews_text ) . '</div></div></div>';
1592
-
1593
- // $fb_cache_name = $fb_shortcode['id'] . $this->rand_string(10);
1594
- // Make sure it's not ajaxing
1595
- // if (!isset($_GET['load_more_ajaxing'])) {
1596
- // Create Cache
1597
- // $FTS_FB_OUTPUT = $this->fts_create_feed_cache($fb_cache_name, $feed_data_rating_overall);
1598
- // }.
1599
- }
1600
-
1601
-
1602
- /**
1603
- * Get Facebook Feed Response
1604
- *
1605
- * @param string $fb_shortcode The facebook shortcode.
1606
- * @param string $fb_cache_name FB cache name.
1607
- * @param string $access_token The Access Token.
1608
- * @param string $language Language.
1609
- * @return array|mixed
1610
- * @throws \Exception
1611
- * @since 1.9.6
1612
- */
1613
- public function get_facebook_feed_response( $fb_shortcode, $fb_cache_name, $access_token, $language ) {
1614
-
1615
- if ( is_plugin_active( 'feed-them-social-combined-streams/feed-them-social-combined-streams.php' ) ) {
1616
- $fts_count_ids = substr_count( $fb_shortcode['id'], ',' );
1617
- } else {
1618
- $fts_count_ids = '';
1619
- }
1620
-
1621
- if ( false !== $this->fts_check_feed_cache_exists( $fb_cache_name ) && ! isset( $_GET['load_more_ajaxing'] ) ) {
1622
- $response = $this->fts_get_feed_cache( $fb_cache_name );
1623
- } else {
1624
- // Page.
1625
- if ( 'page' === $fb_shortcode['type'] && 'page_only' === $fb_shortcode['posts_displayed'] ) {
1626
- $mulit_data = array( 'page_data' => 'https://graph.facebook.com/' . $fb_shortcode['id'] . '?fields=id,name,description&access_token=' . $access_token . $language . '' );
1627
-
1628
- if ( isset( $_REQUEST['next_url'] ) ) {
1629
- $_REQUEST['next_url'] = str_replace( 'access_token=XXX', 'access_token=' . get_option( 'fts_facebook_custom_api_token' ), $_REQUEST['next_url'] );
1630
- }
1631
-
1632
- if ( ! $fts_count_ids >= 1 ) {
1633
- // We cannot add sanitize_text_field here on the $_REQUEST['next_url'] otherwise it will fail to load the contents from the facebook API.
1634
- $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/' . $fb_shortcode['id'] . '/posts?fields=id,caption,attachments,created_time,description,from,icon,link,message,name,object_id,picture,full_picture,place,shares,source,status_type,story,to,type&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1635
- } else {
1636
- $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/posts?ids=' . $fb_shortcode['id'] . '&fields=id,caption,attachments,created_time,description,from,icon,link,message,name,object_id,picture,full_picture,place,shares,source,status_type,story,to,type&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1637
- }
1638
- } elseif (
1639
- // Albums.
1640
- 'albums' === $fb_shortcode['type'] ) {
1641
- $mulit_data = array( 'page_data' => 'https://graph.facebook.com/' . $fb_shortcode['id'] . '?fields=id,name,description,link&access_token=' . $access_token . $language . '' );
1642
- if ( isset( $_REQUEST['next_url'] ) ) {
1643
- $_REQUEST['next_url'] = str_replace( 'access_token=XXX', 'access_token=' . get_option( 'fts_facebook_custom_api_token' ), $_REQUEST['next_url'] );
1644
- }
1645
- // Check If Ajax next URL needs to be used.
1646
- if ( ! $fts_count_ids >= 1 ) {
1647
- $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : wp_unslash( 'https://graph.facebook.com/' . $fb_shortcode['id'] . '/albums?fields=id,photos{images,name,created_time},created_time,name,from,link,cover_photo,count,updated_time,type&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1648
- } else {
1649
- $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : wp_unslash( 'https://graph.facebook.com/albums?ids=' . $fb_shortcode['id'] . '&fields=id,photos{images,name,created_time},created_time,name,from,link,cover_photo,count,updated_time,type&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1650
- }
1651
-
1652
- // $mulit_data['feed_data'] = isset($_REQUEST['next_url']) ? esc_url_raw($_REQUEST['next_url']) : 'https://graph.facebook.com/' . $fb_shortcode['id'] . '/albums?fields=id,created_time,name,from,link,cover_photo,count,updated_time,type&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '';
1653
- } elseif (
1654
- // Album Photos.
1655
- 'album_photos' === $fb_shortcode['type'] ) {
1656
- $mulit_data = array( 'page_data' => 'https://graph.facebook.com/' . $fb_shortcode['id'] . '?fields=id,name,description&access_token=' . $access_token . $language . '' );
1657
- if ( isset( $_REQUEST['next_url'] ) ) {
1658
- $_REQUEST['next_url'] = str_replace( 'access_token=XXX', 'access_token=' . get_option( 'fts_facebook_custom_api_token' ), $_REQUEST['next_url'] );
1659
- }
1660
- // Check If Ajax next URL needs to be used
1661
- // The reason I did not create a whole new else if for the video album is because I did not want to duplicate all the code required to make the video because the videos gallery comes from the photo albums on facebook.
1662
- if ( isset( $fb_shortcode['video_album'] ) && 'yes' === $fb_shortcode['video_album'] ) {
1663
- if ( ! $fts_count_ids >= 1 ) {
1664
- $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/' . $fb_shortcode['id'] . '/videos?fields=id,created_time,description,from,icon,link,message,object_id,picture,place,source,to,type,format,embed_html&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1665
- } else {
1666
- $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/videos?ids=' . $fb_shortcode['id'] . '&fields=id,created_time,description,from,icon,link,message,object_id,picture,place,source,to,type,format,embed_html&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1667
- }
1668
- } elseif ( isset( $fb_shortcode['album_id'] ) && 'photo_stream' === $fb_shortcode['album_id'] ) {
1669
- if ( ! $fts_count_ids >= 1 ) {
1670
- $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/' . $fb_shortcode['id'] . '/photos?fields=id,caption,created_time,description,from,icon,link,message,name,object_id,picture,place,shares,source,status_type,story,to,type&type=uploaded&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1671
- } else {
1672
- $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/photos?ids=' . $fb_shortcode['id'] . '&fields=id,caption,created_time,description,from,icon,link,message,name,object_id,picture,place,shares,source,status_type,story,to,type&type=uploaded&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1673
- }
1674
- } else {
1675
- if ( ! $fts_count_ids >= 1 ) {
1676
- $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/' . $fb_shortcode['album_id'] . '/photos?fields=id,caption,created_time,description,from,icon,link,message,name,object_id,picture,place,shares,source,status_type,story,to,type&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1677
- } else {
1678
- $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/photos?ids=' . $fb_shortcode['album_id'] . '&fields=id,caption,created_time,description,from,icon,link,message,name,object_id,picture,place,shares,source,status_type,story,to,type&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1679
- }
1680
- }
1681
- } elseif ( 'reviews' === $fb_shortcode['type'] ) {
1682
-
1683
- // Reviews.
1684
- if ( is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) ) {
1685
- $fts_facebook_reviews = new FTS_Facebook_Reviews();
1686
- $mulit_data = $fts_facebook_reviews->review_connection( $fb_shortcode, $access_token, $language );
1687
-
1688
- $mulit_data['ratings_data'] = esc_url_raw( 'https://graph.facebook.com/' . $fb_shortcode['id'] . '/?fields=overall_star_rating,rating_count&access_token=' . $access_token . '' );
1689
-
1690
- } else {
1691
- return 'Please Purchase and Activate the Feed Them Social Reviews plugin.';
1692
- exit;
1693
- }
1694
- } else {
1695
- $mulit_data = array( 'page_data' => 'https://graph.facebook.com/' . $fb_shortcode['id'] . '?fields=feed,id,name,description&access_token=' . $access_token . $language . '' );
1696
-
1697
- // Check If Ajax next URL needs to be used.
1698
- if ( ! $fts_count_ids >= 1 ) {
1699
- $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/' . $fb_shortcode['id'] . '/feed?fields=id,caption,created_time,description,from,icon,link,message,name,object_id,picture,full_picture,place,shares,source,status_type,story,to,type&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1700
- } else {
1701
- $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/feed?ids=' . $fb_shortcode['id'] . '&fields=id,caption,created_time,description,from,icon,link,message,name,object_id,picture,full_picture,place,shares,source,status_type,story,to,type&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1702
- }
1703
- }
1704
- $response = $this->fts_get_feed_json( $mulit_data );
1705
-
1706
- if ( ! isset( $_GET['load_more_ajaxing'] ) ) {
1707
- // Error Check.
1708
- $feed_data = json_decode( $response['feed_data'] );
1709
- $fts_error_check = new fts_error_handler();
1710
- $fts_error_check_complete = $fts_error_check->facebook_error_check( $fb_shortcode, $feed_data );
1711
- if ( is_array( $fts_error_check_complete ) && true === $fts_error_check_complete[0] ) {
1712
-
1713
- // If old Cache exists use it instead of showing an error.
1714
- if ( true === $this->fts_check_feed_cache_exists( $fb_cache_name, true ) ) {
1715
-
1716
- // If Current user is Admin and Cache exists for use then still show Admin the error for debugging purposes.
1717
- if ( current_user_can( 'administrator' ) ) {
1718
- echo wp_kses(
1719
- $fts_error_check_complete[1] . ' <em>**NOTE** This error is only shown to logged in Admins of this WordPress install</em>',
1720
- array(
1721
- 'a' => array(
1722
- 'href' => array(),
1723
- 'title' => array(),
1724
- ),
1725
- 'br' => array(),
1726
- 'em' => array(),
1727
- 'strong' => array(),
1728
- )
1729
- );
1730
- }
1731
-
1732
- // Return Cache because it exists in Database. Better than showing nothing right?
1733
- return $this->fts_get_feed_cache( $fb_cache_name, true );
1734
- }
1735
- // If User is Admin and no Old cache is saved in database for use.
1736
- if ( current_user_can( 'administrator' ) ) {
1737
- return array( false, $fts_error_check_complete[1] );
1738
- }
1739
- }
1740
- }
1741
-
1742
- // Make sure it's not ajaxing.
1743
- if ( ! empty( $response['feed_data'] ) ) {
1744
- // Create Cache.
1745
- $this->fts_create_feed_cache( $fb_cache_name, $response );
1746
- }
1747
- } // end main else.
1748
-
1749
- return $response;
1750
-
1751
- }
1752
-
1753
-
1754
- /**
1755
- * Get Facebook Feed Dynamic Name
1756
- *
1757
- * @param string $fb_shortcode The facebook feed shortcode.
1758
- * @return mixed
1759
- * @since 1.9.6
1760
- */
1761
- public function get_facebook_feed_dynamic_name( $fb_shortcode ) {
1762
-
1763
- return $_REQUEST['fts_dynamic_name'] = sanitize_key( $this->fts_rand_string( 10 ) . '_' . $fb_shortcode['type'] );
1764
-
1765
- }
1766
-
1767
- /**
1768
- * Get Facebook Feed Dynamic Class Name
1769
- *
1770
- * @param null $fts_dynamic_name Our Dynamic Name for ajax.
1771
- * @return string
1772
- * @since 1.9.6
1773
- */
1774
- public function get_facebook_feed_dynamic_class_name( $fts_dynamic_name = null ) {
1775
- $fts_dynamic_class_name = '';
1776
- if ( isset( $fts_dynamic_name ) ) {
1777
- $fts_dynamic_class_name = 'feed_dynamic_class' . sanitize_key( $_REQUEST['fts_dynamic_name'] );
1778
- }
1779
- return $fts_dynamic_class_name;
1780
- }
1781
-
1782
-
1783
- /**
1784
- * Get Post Info
1785
- *
1786
- * For Facebook.
1787
- *
1788
- * @param string $feed_data The facebook contents.
1789
- * @param string $fb_shortcode FB cache name.
1790
- * @param string $access_token The Access Token.
1791
- * @param string $language Language.
1792
- * @return array|mixed
1793
- * @since 1.9.6
1794
- */
1795
- public function get_post_info( $feed_data, $fb_shortcode, $access_token, $language, $fb_cache_name ) {
1796
- $developer_mode = get_option( 'fts_clear_cache_developer_mode' );
1797
-
1798
- if ( 'album_photos' === $fb_shortcode['type'] ) {
1799
- $fb_post_data_cache = 'fb_' . $fb_shortcode['type'] . '_post_' . $fb_shortcode['album_id'] . '_num' . $fb_shortcode['posts'] . '';
1800
- } else {
1801
- $fb_post_data_cache = 'fb_' . $fb_shortcode['type'] . '_post_' . $fb_shortcode['id'] . '_num' . $fb_shortcode['posts'] . '';
1802
- }
1803
- if ( false !== $this->fts_check_feed_cache_exists( $fb_post_data_cache ) && ! isset( $_GET['load_more_ajaxing'] ) ) {
1804
- $response_post_array = $this->fts_get_feed_cache( $fb_post_data_cache );
1805
-
1806
- } else {
1807
- // Build the big post counter.
1808
- $fb_post_array = array();
1809
- // Single Events Array.
1810
- $set_zero = 0;
1811
- foreach ( $feed_data->data as $counter ) {
1812
-
1813
- $counter->id = isset( $counter->id ) ? $counter->id : '';
1814
-
1815
- if ( $set_zero === $fb_shortcode['posts'] ) {
1816
- break;
1817
- }
1818
-
1819
- $fb_type = isset( $counter->type ) ? $counter->type : '';
1820
- $post_data_key = isset( $counter->object_id ) ? $counter->object_id : $counter->id;
1821
-
1822
- // Likes & Comments.
1823
- $fb_post_array[ $post_data_key . '_likes' ] = 'https://graph.facebook.com/' . $post_data_key . '/reactions?summary=1&access_token=' . $access_token;
1824
- $fb_post_array[ $post_data_key . '_comments' ] = 'https://graph.facebook.com/' . $post_data_key . '/comments?summary=1&access_token=' . $access_token;
1825
- // Video.
1826
- if ( 'video' === $fb_type ) {
1827
- $fb_post_array[ $post_data_key . '_video' ] = 'https://graph.facebook.com/' . $post_data_key;
1828
- }
1829
- // Photo.
1830
- $fb_album_cover = isset( $counter->cover_photo->id ) ? $counter->cover_photo->id : '';
1831
- if ( 'albums' === $fb_shortcode['type'] && ! $fb_album_cover ) {
1832
- unset( $counter );
1833
- continue;
1834
- }
1835
- if ( 'albums' === $fb_shortcode['type'] ) {
1836
- $fb_post_array[ $fb_album_cover . '_photo' ] = 'https://graph.facebook.com/' . $fb_album_cover;
1837
- }
1838
- if ( 'hashtag' === $fb_shortcode['type'] ) {
1839
- $fb_post_array[ $post_data_key . '_photo' ] = 'https://graph.facebook.com/' . $counter->source;
1840
- }
1841
- // GROUP Photo.
1842
- if ( 'group' === $fb_shortcode['type'] ) {
1843
- $fb_post_array[ $post_data_key . '_group_post_photo' ] = 'https://graph.facebook.com/' . $counter->id . '?fields=picture,full_picture&access_token=' . $access_token;
1844
- }
1845
-
1846
- $set_zero++;
1847
- }
1848
-
1849
- $fts_error_check = new fts_error_handler();
1850
- $fts_error_check_complete = $fts_error_check->facebook_error_check( $fb_shortcode, $feed_data );
1851
- if ( is_array( $fts_error_check_complete ) && true === $fts_error_check_complete[0] ) {
1852
-
1853
- // If old Cache exists use it instead of showing an error.
1854
- if ( true === $this->fts_check_feed_cache_exists( $fb_cache_name, true ) ) {
1855
-
1856
- // Return Cache because it exists in Database. Better than showing nothing right?
1857
- return $this->fts_get_feed_cache( $fb_cache_name, true );
1858
- }
1859
- }
1860
-
1861
- // Response.
1862
- $response_post_array = $this->fts_get_feed_json( $fb_post_array );
1863
- // Make sure it's not ajaxing.
1864
- if ( ! isset( $_GET['load_more_ajaxing'] ) ) {
1865
- // Create Cache.
1866
- $this->fts_create_feed_cache( $fb_post_data_cache, $response_post_array );
1867
- }
1868
- }
1869
- // SHOW THE POST RESPONSE PRINT_R
1870
- // echo'<pre>';
1871
- // print_r($response_post_array);
1872
- // echo'</pre>';.
1873
- return $response_post_array;
1874
- }
1875
-
1876
-
1877
- /**
1878
- * Get Post Info
1879
- *
1880
- * For Facebook.
1881
- *
1882
- * @param string $feed_data The facebook contents.
1883
- * @param string $fb_shortcode FB cache name.
1884
- * @param string $access_token The Access Token.
1885
- * @param string $language Language.
1886
- * @return array|mixed
1887
- * @since 2.1.6
1888
- */
1889
- public function get_event_post_info( $feed_data, $fb_shortcode, $access_token, $language ) {
1890
- $developer_mode = get_option( 'fts_clear_cache_developer_mode' );
1891
-
1892
- $fb_event_post_data_cache = 'fbe_' . $fb_shortcode['type'] . '_post_' . $fb_shortcode['id'] . '_num' . $fb_shortcode['posts'] . '';
1893
- if ( false !== $this->fts_check_feed_cache_exists( $fb_event_post_data_cache ) && ! isset( $_GET['load_more_ajaxing'] ) ) {
1894
- $response_event_post_array = $this->fts_get_feed_cache( $fb_event_post_data_cache );
1895
- } else {
1896
- // Single Events Array.
1897
- $fb_single_events_array = array();
1898
- $set_zero = 0;
1899
- foreach ( $feed_data->data as $counter ) {
1900
-
1901
- $counter->id = isset( $counter->id ) ? $counter->id : '';
1902
-
1903
- if ( $set_zero === $fb_shortcode['posts'] ) {
1904
- break;
1905
- }
1906
-
1907
- $single_event_id = $counter->id;
1908
- $language = isset( $language ) ? $language : '';
1909
- // Event Info, Time etc.
1910
- $fb_single_events_array[ 'event_single_' . $single_event_id . '_info' ] = 'https://graph.facebook.com/' . $single_event_id . '/?access_token=' . $access_token . $language;
1911
- // Event Location.
1912
- $fb_single_events_array[ 'event_single_' . $single_event_id . '_location' ] = 'https://graph.facebook.com/' . $single_event_id . '/?fields=place&access_token=' . $access_token . $language;
1913
- // Event Cover Photo.
1914
- $fb_single_events_array[ 'event_single_' . $single_event_id . '_cover_photo' ] = 'https://graph.facebook.com/' . $single_event_id . '/?fields=cover&access_token=' . $access_token . $language;
1915
- // Event Ticket Info.
1916
- $fb_single_events_array[ 'event_single_' . $single_event_id . '_ticket_info' ] = 'https://graph.facebook.com/' . $single_event_id . '/?fields=ticket_uri&access_token=' . $access_token . $language;
1917
-
1918
- $set_zero++;
1919
- }
1920
-
1921
- $response_event_post_array = $this->fts_get_feed_json( $fb_single_events_array );
1922
- // Create Cache.
1923
- $this->fts_create_feed_cache( $fb_event_post_data_cache, $response_event_post_array );
1924
-
1925
- }
1926
- // SHOW THE $response_event_post_array FEED PRINT_R
1927
- // '<pre>';.
1928
- // print_r($response_event_post_array);
1929
- // echo'</pre>';.
1930
- return $response_event_post_array;
1931
- }
1932
-
1933
-
1934
- /**
1935
- * FB Social Button Placement
1936
- *
1937
- * @param string $fb_shortcode The facebook contents.
1938
- * @param string $access_token The Access Token.
1939
- * @param string $share_loc Language.
1940
- * @return string|void
1941
- * @since 2.0.1
1942
- */
1943
- public function fb_social_btn_placement( $fb_shortcode, $access_token, $share_loc ) {
1944
- // Don't do it for these!
1945
- if ( 'group' === $fb_shortcode['type'] || 'event' === $fb_shortcode['type'] || isset( $fb_shortcode['hide_like_option'] ) && 'yes' === $fb_shortcode['hide_like_option'] ) {
1946
- return;
1947
- }
1948
- // Facebook Follow Button Options.
1949
- $fb_show_follow_btn = get_option( 'fb_show_follow_btn' );
1950
-
1951
- if ( isset( $fb_shortcode['show_follow_btn_where'] ) && '' !== $fb_shortcode['show_follow_btn_where'] ) {
1952
- if ( 'above_title' === $fb_shortcode['show_follow_btn_where'] ) {
1953
- $fb_show_follow_btn_where = 'fb-like-top-above-title';
1954
- } elseif ( 'below_title' === $fb_shortcode['show_follow_btn_where'] ) {
1955
- $fb_show_follow_btn_where = 'fb-like-top-below-title';
1956
- } elseif ( 'bottom' === $fb_shortcode['show_follow_btn_where'] ) {
1957
- $fb_show_follow_btn_where = 'fb-like-below';
1958
- }
1959
- } else {
1960
- $fb_show_follow_btn_where = get_option( 'fb_show_follow_btn_where' );
1961
- }
1962
-
1963
- if ( ! isset( $_GET['load_more_ajaxing'] ) ) {
1964
-
1965
- $like_option_align_final = isset( $fb_shortcode['like_option_align'] ) ? 'fts-fb-social-btn-' . $fb_shortcode['like_option_align'] . '' : '';
1966
-
1967
- if ( $share_loc === $fb_show_follow_btn_where ) {
1968
- switch ( $fb_show_follow_btn_where ) {
1969
- case 'fb-like-top-above-title':
1970
- // Top Above Title.
1971
- if ( isset( $fb_show_follow_btn ) && 'dont-display' !== $fb_show_follow_btn ) {
1972
- echo '<div class="fb-social-btn-top ' . esc_attr( $like_option_align_final ) . '">';
1973
- $this->social_follow_button( 'facebook', $fb_shortcode['id'], $access_token, $fb_shortcode );
1974
- echo '</div>';
1975
- }
1976
- break;
1977
- // Top Below Title.
1978
- case 'fb-like-top-below-title':
1979
- if ( isset( $fb_show_follow_btn ) && 'dont-display' !== $fb_show_follow_btn ) {
1980
- echo '<div class="fb-social-btn-below-description ' . esc_attr( $like_option_align_final ) . '">';
1981
- $this->social_follow_button( 'facebook', $fb_shortcode['id'], $access_token, $fb_shortcode );
1982
- echo '</div>';
1983
- }
1984
- break;
1985
- // Bottom.
1986
- case 'fb-like-below':
1987
- if ( isset( $fb_show_follow_btn ) && 'dont-display' !== $fb_show_follow_btn ) {
1988
- echo '<div class="fb-social-btn-bottom ' . esc_attr( $like_option_align_final ) . '">';
1989
- $this->social_follow_button( 'facebook', $fb_shortcode['id'], $access_token, $fb_shortcode );
1990
- echo '</div>';
1991
- }
1992
- break;
1993
- }
1994
- }
1995
- }
1996
- }
1997
-
1998
- /**
1999
- * FTS Custom Trim Words
2000
- *
2001
- * Not using this anymore but keeping it as a fallback function for the combined if user has not updated the free version before the combined extension
2002
- *
2003
- * @param string $text The description text.
2004
- * @param int $num_words Number of words you want to be showm.
2005
- * @param string $more The ...
2006
- * @return mixed
2007
- * @since 1.9.6
2008
- */
2009
- public function fts_custom_trim_words( $text, $num_words = 45, $more ) {
2010
- ! empty( $num_words ) && 0 !== $num_words ? $more = __( '...' ) : '';
2011
- $text = nl2br( $text );
2012
- // Filter for Hashtags and Mentions Before returning.
2013
- $text = $this->fts_facebook_tag_filter( $text );
2014
- $text = strip_shortcodes( $text );
2015
- // Add tags that you don't want stripped.
2016
- $text = strip_tags( $text, '<strong><br><em><i><a>' );
2017
- $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY );
2018
- $sep = ' ';
2019
- if ( count( $words_array ) > $num_words ) {
2020
- array_pop( $words_array );
2021
- $text = implode( $sep, $words_array );
2022
- $text = $text . $more;
2023
- } else {
2024
- $text = implode( $sep, $words_array );
2025
- }
2026
- return wpautop( $text );
2027
- }
2028
-
2029
- /**
2030
- * FTS Facebook Tag Filter
2031
- *
2032
- * Tags Filter (return clean tags)
2033
- *
2034
- * @param string $fb_description Facebook Description.
2035
- * @return mixed
2036
- * @since 1.9.6
2037
- */
2038
- public function fts_facebook_tag_filter( $fb_description ) {
2039
- // Converts URLs to Links.
2040
- $fb_description = preg_replace( '@(?!(?!.*?<a)[^<]*<\/a>)(?:(?:https?|ftp|file)://|www\.|ftp\.)[-A-‌​Z0-9+&#/%=~_|$?!:,.]*[A-Z0-9+&#/%=~_|$]@i', '<a href="\0" target="_blank" rel="noreferrer">\0</a>', $fb_description );
2041
-
2042
- $splitano = explode( 'www', $fb_description );
2043
- $count = count( $splitano );
2044
- $return_value = '';
2045
-
2046
- for ( $i = 0; $i < $count; $i++ ) {
2047
- if ( 'href=' === substr( $splitano[ $i ], -6, 5 ) ) {
2048
- $return_value .= $splitano[ $i ] . 'http://www';
2049
- } elseif ( $i < $count - 1 ) {
2050
- $return_value .= $splitano[ $i ] . 'www';
2051
- } else {
2052
- $return_value .= $splitano[ $i ];
2053
- }
2054
- }
2055
- // Mentions.
2056
- $return_value = preg_replace( '/@+(\w+)/u', '<a href="https://www.facebook.com/$1" target="_blank" rel="noreferrer">@$1</a>', $return_value );
2057
- // Hash tags.
2058
- $return_value = preg_replace( '/#+(\w+)/u', '<a href="https://www.facebook.com/hashtag/$1" target="_blank" rel="noreferrer">#$1</a>', $return_value );
2059
-
2060
- return $return_value;
2061
- }
2062
-
2063
- /**
2064
- * Load PopUp Scripts
2065
- *
2066
- * @param string $fb_shortcode The Facebook feed shortcode.
2067
- * @since 1.9.6
2068
- */
2069
- public function load_popup_scripts( $fb_shortcode ) {
2070
- if ( 'yes' === $fb_shortcode['popup'] ) {
2071
- // it's ok if these styles & scripts load at the bottom of the page.
2072
- $fts_fix_magnific = get_option( 'fts_fix_magnific' ) ? get_option( 'fts_fix_magnific' ) : '';
2073
- if ( isset( $fts_fix_magnific ) && '1' !== $fts_fix_magnific ) {
2074
- wp_enqueue_style( 'fts-popup', plugins_url( 'feed-them-social/feeds/css/magnific-popup.css' ), array(), FTS_CURRENT_VERSION, false );
2075
- }
2076
- wp_enqueue_script( 'fts-popup-js', plugins_url( 'feed-them-social/feeds/js/magnific-popup.js' ), array(), FTS_CURRENT_VERSION, false );
2077
- wp_enqueue_script( 'fts-images-loaded', plugins_url( 'feed-them-social/feeds/js/imagesloaded.pkgd.min.js' ), array(), FTS_CURRENT_VERSION, false );
2078
- if ( ! isset( $fb_shortcode['video_album'] ) && 'yes' === $fb_shortcode['video_album'] ) {
2079
- wp_enqueue_script( 'fts-global', plugins_url( 'feed-them-social/feeds/js/fts-global.js' ), array( 'jquery' ), FTS_CURRENT_VERSION, false );
2080
- }
2081
- }
2082
- }
2083
-
2084
- /**
2085
- * FTS Facebook LoadMore
2086
- *
2087
- * @param string $atts The shortcode attributes.
2088
- * @param string $feed_data The Feed data.
2089
- * @param string $fb_type The type of facebook feed.
2090
- * @param string $fb_shortcode The Facebook feed shortcode.
2091
- * @since 1.9.6
2092
- */
2093
- public function fts_facebook_loadmore( $atts, $feed_data, $fb_type, $fb_shortcode ) {
2094
- if ( ( isset( $fb_shortcode['loadmore'] ) && 'button' === $fb_shortcode['loadmore'] || isset( $fb_shortcode['loadmore'] ) && 'autoscroll' === $fb_shortcode['loadmore'] ) && ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && 'reviews' !== $fb_shortcode['type'] || is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && 'reviews' === $fb_shortcode['type'] ) ) {
2095
-
2096
- $fb_load_more_text = get_option( 'fb_load_more_text' ) ? get_option( 'fb_load_more_text' ) : esc_html( 'Load More', 'feed-them-social' );
2097
- $fb_no_more_posts_text = get_option( 'fb_no_more_posts_text' ) ? get_option( 'fb_no_more_posts_text' ) : esc_html( 'No More Posts', 'feed-them-social' );
2098
- $fb_no_more_photos_text = get_option( 'fb_no_more_photos_text' ) ? get_option( 'fb_no_more_photos_text' ) : esc_html( 'No More Photos', 'feed-them-social' );
2099
- $fb_no_more_videos_text = get_option( 'fb_no_more_videos_text' ) ? get_option( 'fb_no_more_videos_text' ) : esc_html( 'No More Videos', 'feed-them-social' );
2100
- $fb_no_more_reviews_text = get_option( 'fb_no_more_reviews_text' ) ? get_option( 'fb_no_more_reviews_text' ) : esc_html( 'No More Reviews', 'feed-them-social' );
2101
-
2102
- // Load More BUTTON Start.
2103
- $next_url = isset( $feed_data->paging->next ) ? $feed_data->paging->next : '';
2104
-
2105
- $posts = isset( $fb_shortcode['posts'] ) ? $fb_shortcode['posts'] : '';
2106
- $loadmore_count = isset( $fb_shortcode['loadmore_count'] ) && '' !== $fb_shortcode['loadmore_count'] ? $fb_shortcode['loadmore_count'] : '';
2107
- // we check to see if the loadmore count number is set and if so pass that as the new count number when fetching the next set of posts.
2108
- $_REQUEST['next_url'] = '' !== $loadmore_count ? str_replace( "limit=$posts", "limit=$loadmore_count", $next_url ) : $next_url;
2109
-
2110
- $access_token = is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) ? 'access_token=' . get_option( 'fts_facebook_custom_api_token_biz' ) : 'access_token=' . get_option( 'fts_facebook_custom_api_token' );
2111
- $_REQUEST['next_url'] = str_replace( $access_token, 'access_token=XXX', $next_url );
2112
-
2113
- echo '<script>';
2114
- echo 'var nextURL_' . esc_js( $_REQUEST['fts_dynamic_name'] ) . '= "' . esc_url_raw( $_REQUEST['next_url'] ) . '";';
2115
- echo '</script>';
2116
-
2117
- // Make sure it's not ajaxing.
2118
- if ( ! isset( $_GET['load_more_ajaxing'] ) && ! isset( $_REQUEST['fts_no_more_posts'] ) && ! empty( $fb_shortcode['loadmore'] ) ) {
2119
- $fts_dynamic_name = $_REQUEST['fts_dynamic_name'];
2120
- $time = time();
2121
- $nonce = wp_create_nonce( $time . 'load-more-nonce' );
2122
- $fts_dynamic_class_name = $this->get_fts_dynamic_class_name();
2123
- echo '<script>';
2124
- echo 'jQuery(document).ready(function() {';
2125
- if ( 'autoscroll' === $fb_shortcode['loadmore'] ) {
2126
- // this is where we do SCROLL function to LOADMORE if = autoscroll in shortcode.
2127
- echo 'jQuery(".' . esc_js( $fts_dynamic_class_name ) . '").bind("scroll",function() {';
2128
- echo 'if(jQuery(this).scrollTop() + jQuery(this).innerHeight() >= jQuery(this)[0].scrollHeight) {';
2129
- } else {
2130
- // this is where we do CLICK function to LOADMORE if = button in shortcode.
2131
- echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").click(function() {';
2132
- }
2133
- echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").addClass("fts-fb-spinner");';
2134
- echo 'var button = jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").html("<div class=\'bounce1\'></div><div class=\'bounce2\'></div><div class=\'bounce3\'></div>");';
2135
- echo 'console.log(button);';
2136
-
2137
- echo 'var yes_ajax = "yes";';
2138
- echo 'var fts_d_name = "' . esc_js( $fts_dynamic_name ) . '";';
2139
- echo 'var fts_security = "' . esc_js( $nonce ) . '";';
2140
- echo 'var fts_time = "' . esc_js( $time ) . '";';
2141
-
2142
- echo 'var feed_name = "fts_facebook";';
2143
- echo 'var loadmore_count = "posts=' . esc_js( $fb_shortcode['loadmore_count'] ) . '";';
2144
- echo 'var feed_attributes = ' . json_encode( $atts ) . ';';
2145
-
2146
- echo 'jQuery.ajax({';
2147
- echo 'data: {action: "my_fts_fb_load_more", next_url: nextURL_' . esc_js( $fts_dynamic_name ) . ', fts_dynamic_name: fts_d_name, feed_name: feed_name, loadmore_count: loadmore_count, feed_attributes: feed_attributes, load_more_ajaxing: yes_ajax, fts_security: fts_security, fts_time: fts_time},';
2148
- echo 'type: "GET",';
2149
- echo 'url: "' . esc_url( admin_url( 'admin-ajax.php' ) ) . '",';
2150
- echo 'success: function( data ) {';
2151
- echo 'console.log("Well Done and got this from sever: " + data);';
2152
- if ( $fb_type && 'albums' === $fb_shortcode['type'] || $fb_type && 'album_photos' === $fb_shortcode['type'] && 'yes' !== $fb_shortcode['video_album'] || 'yes' === $fb_shortcode['grid'] ) {
2153
- echo 'jQuery(".' . esc_js( $fts_dynamic_class_name ) . '").append(data).filter(".' . esc_js( $fts_dynamic_class_name ) . '").html();';
2154
- // if (isset($fb_shortcode['image_stack_animation']) && $fb_shortcode['image_stack_animation'] == 'yes') {.
2155
- echo 'jQuery(".' . esc_js( $fts_dynamic_class_name ) . '").masonry( "reloadItems");';
2156
- echo 'jQuery(".' . esc_js( $fts_dynamic_class_name ) . '").masonry("layout");';
2157
-
2158
- echo 'setTimeout(function() {';
2159
- // Do something after 3 seconds
2160
- // This can be direct code, or call to some other function.
2161
- echo 'jQuery(".' . esc_js( $fts_dynamic_class_name ) . '").masonry("layout");';
2162
- echo '}, 500);';
2163
-
2164
- // }.
2165
- echo 'if(!nextURL_' . esc_js( $_REQUEST['fts_dynamic_name'] ) . ' || nextURL_' . esc_js( $_REQUEST['fts_dynamic_name'] ) . ' == "no more"){';
2166
- if ( 'reviews' === $fb_shortcode['type'] ) {
2167
- echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").replaceWith(\'<div class="fts-fb-load-more no-more-posts-fts-fb">' . esc_html( $fb_no_more_reviews_text ) . '</div>\');';
2168
- } elseif ( 'videos' === $fb_shortcode['type'] ) {
2169
- echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").replaceWith(\'<div class="fts-fb-load-more no-more-posts-fts-fb">' . esc_html( $fb_no_more_videos_text ) . '</div>\');';
2170
- } else {
2171
- echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").replaceWith(\'<div class="fts-fb-load-more no-more-posts-fts-fb">' . esc_html( $fb_no_more_photos_text ) . '</div>\');';
2172
- }
2173
-
2174
- echo ' jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").removeAttr("id");';
2175
- echo 'jQuery(".' . esc_js( $fts_dynamic_class_name ) . '").unbind("scroll");';
2176
- echo '}';
2177
- } else {
2178
- if ( isset( $fb_shortcode['video_album'] ) && 'yes' === $fb_shortcode['video_album'] ) {
2179
- echo 'var result = jQuery(data).insertBefore( jQuery("#output_' . esc_js( $fts_dynamic_name ) . '") );';
2180
- echo 'var result = jQuery(".feed_dynamic_' . esc_js( $fts_dynamic_name ) . '_album_photos").append(data).filter("#output_' . esc_js( $fts_dynamic_name ) . '").html();';
2181
- } else {
2182
- echo 'var result = jQuery("#output_' . esc_js( $fts_dynamic_name ) . '").append(data).filter("#output_' . esc_js( $fts_dynamic_name ) . '").html();';
2183
- }
2184
- echo 'jQuery("#output_' . esc_js( $fts_dynamic_name ) . '").html(result);';
2185
- echo 'if(!nextURL_' . esc_js( $_REQUEST['fts_dynamic_name'] ) . ' || nextURL_' . esc_js( $_REQUEST['fts_dynamic_name'] ) . ' == "no more"){';
2186
- // Reviews.
2187
- if ( 'reviews' === $fb_shortcode['type'] ) {
2188
- echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").replaceWith(\'<div class="fts-fb-load-more no-more-posts-fts-fb">' . esc_html( $fb_no_more_reviews_text ) . '</div>\');';
2189
- } else {
2190
- echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").replaceWith(\'<div class="fts-fb-load-more no-more-posts-fts-fb">' . esc_html( $fb_no_more_posts_text ) . '</div>\');';
2191
- }
2192
- echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").removeAttr("id");';
2193
- echo 'jQuery(".' . esc_js( $fts_dynamic_class_name ) . '").unbind("scroll");';
2194
- echo '}';
2195
-
2196
- }
2197
- echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").html("' . esc_html( $fb_load_more_text ) . '");';
2198
- // jQuery("#loadMore_'.$fts_dynamic_name.'").removeClass("flip360-fts-load-more");.
2199
- echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").removeClass("fts-fb-spinner");';
2200
- if ( isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ) {
2201
- // We return this function again otherwise the popup won't work correctly for the newly loaded items.
2202
- echo 'jQuery.fn.slickFacebookPopUpFunction();';
2203
- }
2204
- // Reload the share each funcion otherwise you can't open share option..
2205
- echo 'jQuery.fn.ftsShare();slickremixImageResizingFacebook2();slickremixImageResizingFacebook3();';
2206
-
2207
- echo '}';
2208
- echo '});';
2209
- // end of ajax().
2210
- echo 'return false;';
2211
- // string $scrollMore is at top of this js script. acception for scroll option closing tag.
2212
- if ( 'autoscroll' === $fb_shortcode['loadmore'] ) {
2213
- echo '}';
2214
- // end of scroll ajax load.
2215
- }
2216
- echo '});';
2217
- // end of document.ready.
2218
- echo '});';
2219
- // end of form.submit.
2220
- echo '</script>';
2221
- }
2222
- // End Check.
2223
- // main closing div not included in ajax check so we can close the wrap at all times.
2224
- // Make sure it's not ajaxing.
2225
- if ( ! isset( $_GET['load_more_ajaxing'] ) ) {
2226
- $fts_dynamic_name = $_REQUEST['fts_dynamic_name'];
2227
- // this div returns outputs our ajax request via jquery appenc html from above style="display:nonee;".
2228
- echo '<div id="output_' . esc_attr( $fts_dynamic_name ) . '" class="fts-fb-load-more-output"></div>';
2229
- if ( ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && 'reviews' !== $fb_shortcode['type'] || is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && 'reviews' === $fb_shortcode['type'] ) && 'autoscroll' === $fb_shortcode['loadmore'] ) {
2230
- echo '<div id="loadMore_' . esc_attr( $fts_dynamic_name ) . '" class="fts-fb-load-more fts-fb-autoscroll-loader">Facebook</div>';
2231
- }
2232
- }
2233
- }
2234
- // end of if loadmore is button or autoscroll.
2235
- }
2236
- // end fts_facebook_loadmore().
2237
-
2238
- /**
2239
- * Random String
2240
- *
2241
- * Create a random string
2242
- *
2243
- * @param string $length How many character to randomize.
2244
- * @return mixed
2245
- * @since 1.9.6
2246
- */
2247
- public function fts_rand_string( $length = 10 ) {
2248
- $characters = 'abcdefghijklmnopqrstuvwxyz';
2249
- $characters_length = strlen( $characters );
2250
- $random_string = '';
2251
- for ( $i = 0; $i < $length; $i++ ) {
2252
- $random_string .= $characters[ wp_rand( 0, $characters_length - 1 ) ];
2253
- }
2254
-
2255
- return $random_string;
2256
- }
 
 
 
 
 
 
 
 
 
 
 
2257
  }//end class
7
  * @since 1.9.6
8
  */
9
  class FTS_Facebook_Feed extends feed_them_social_functions {
10
+ /**
11
+ * Construct
12
+ *
13
+ * Facebook Feed constructor.
14
+ *
15
+ * @since 1.9.6
16
+ */
17
+ public function __construct() {
18
+ add_shortcode( 'fts_facebook_group', array( $this, 'fts_fb_func' ) );
19
+ add_shortcode( 'fts_facebook_page', array( $this, 'fts_fb_func' ) );
20
+ add_shortcode( 'fts_facebook_event', array( $this, 'fts_fb_func' ) );
21
+ add_shortcode( 'fts_facebook', array( $this, 'fts_fb_func' ) );
22
+ add_action( 'wp_enqueue_scripts', array( $this, 'fts_fb_head' ) );
23
+ }
24
+
25
+ /**
26
+ * FTS FB Head
27
+ *
28
+ * Add Styles and Scripts functions.
29
+ *
30
+ * @since 1.9.6
31
+ */
32
+ public function fts_fb_head() {
33
+ wp_enqueue_style( 'fts-feeds', plugins_url( 'feed-them-social/feeds/css/styles.css' ), array(), FTS_CURRENT_VERSION, false );
34
+
35
+ if ( is_plugin_active( 'feed-them-social/feed-them.php' ) && is_plugin_active( 'feed-them-carousel-premium/feed-them-carousel-premium.php' ) && is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) ) {
36
+ wp_enqueue_script( 'fts-feeds', plugins_url( 'feed-them-carousel-premium/feeds/js/jquery.cycle2.js' ), array(), FTS_CURRENT_VERSION, false );
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Date Sort
42
+ *
43
+ * Date sort option for multiple feeds in a shortcode.
44
+ *
45
+ * @param string $a First Date.
46
+ * @param string $b Second Date.
47
+ * @return false|int
48
+ * @since 1.9.6
49
+ */
50
+ public function dateSort( $a, $b ) {
51
+ $date_a = strtotime( $a->created_time );
52
+ $date_b = strtotime( $b->created_time );
53
+ return ( $date_b - $date_a );
54
+ }
55
+
56
+
57
+ /**
58
+ * FTS FB Func
59
+ *
60
+ * Display Facebook Feed.
61
+ *
62
+ * @param string $atts Shortcode attributes.
63
+ * @return string
64
+ * @since 1.9.6
65
+ */
66
+ public function fts_fb_func( $atts ) {
67
+ // masonry snippet in fts-global.
68
+ wp_enqueue_script( 'fts-global', plugins_url( 'feed-them-social/feeds/js/fts-global.js' ), array( 'jquery' ), FTS_CURRENT_VERSION, false );
69
+ $developer_mode = 'on';
70
+ // Make sure everything is reset.
71
+ include_once ABSPATH . 'wp-admin/includes/plugin.php';
72
+ // Eventually add premium page file.
73
+ if ( is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) ) {
74
+
75
+ $fts_facebook_reviews = new FTS_Facebook_Reviews();
76
+ $review_atts = $fts_facebook_reviews->shortcode_attributes();
77
+ $fb_shortcode = shortcode_atts( $review_atts, $atts );
78
+ // Load up some scripts for popup.
79
+ $this->load_popup_scripts( $fb_shortcode );
80
+ } elseif ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) ) {
81
+ include WP_PLUGIN_DIR . '/feed-them-premium/feeds/facebook/facebook-premium-feed.php';
82
+ // Doing this to phase out the invalid snake case.
83
+ $fb_shortcode = $FB_Shortcode;
84
+ // Load up some scripts for popup.
85
+ $this->load_popup_scripts( $fb_shortcode );
86
+ } elseif ( is_plugin_active( 'feed-them-social-combined-streams/feed-them-social-combined-streams.php' ) && ! is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) ) {
87
+ // Doing this to phase out the invalid snake case.
88
+ $fb_shortcode = $FB_Shortcode;
89
+ $fb_shortcode = shortcode_atts(
90
+ array(
91
+ 'id' => '',
92
+ 'type' => '',
93
+ 'posts' => '',
94
+ 'posts_displayed' => '',
95
+ 'height' => '',
96
+ 'album_id' => '',
97
+ 'image_width' => '',
98
+ 'image_height' => '',
99
+ 'space_between_photos' => '',
100
+ 'hide_date_likes_comments' => '',
101
+ 'center_container' => '',
102
+ 'image_stack_animation' => '',
103
+ 'image_position_lr' => '',
104
+ 'image_position_top' => '',
105
+ 'hide_comments_popup' => '',
106
+ // only works with combined FB streams otherwise you need the premium version.
107
+ 'popup' => '',
108
+ 'words' => '',
109
+ 'grid' => '',
110
+ 'colmn_width' => '',
111
+ 'space_between_posts' => '',
112
+ // new show media on top options.
113
+ 'show_media' => '',
114
+ 'show_date' => '',
115
+ 'show_name' => '',
116
+ // 'access_token' => '',
117
+ ),
118
+ $atts
119
+ );
120
+ if ( null === $fb_shortcode['posts'] ) {
121
+ $fb_shortcode['posts'] = '6';
122
+ }
123
+ } else {
124
+ $fb_shortcode = shortcode_atts(
125
+ array(
126
+ 'id' => '',
127
+ 'type' => '',
128
+ 'posts' => '',
129
+ 'description' => 'yes',
130
+ 'posts_displayed' => '',
131
+ 'height' => '',
132
+ 'album_id' => '',
133
+ 'image_width' => '',
134
+ 'image_height' => '',
135
+ 'space_between_photos' => '',
136
+ 'hide_date_likes_comments' => '',
137
+ 'center_container' => '',
138
+ 'image_stack_animation' => '',
139
+ 'image_position_lr' => '',
140
+ 'image_position_top' => '',
141
+ 'hide_comments_popup' => '',
142
+ 'access_token' => '',
143
+ ),
144
+ $atts
145
+ );
146
+ if ( null === $fb_shortcode['posts'] ) {
147
+ $fb_shortcode['posts'] = '6';
148
+ }
149
+ }
150
+
151
+ if ( 'album_videos' === $fb_shortcode['type'] ) {
152
+ $fb_shortcode['type'] = 'album_photos';
153
+ $fb_shortcode['video_album'] = 'yes';
154
+ $fb_shortcode['album_id'] = 'photo_stream';
155
+ if ( isset( $fb_shortcode['loadmore_btn_maxwidth'] ) && ! empty( $fb_shortcode['loadmore_btn_maxwidth'] ) ) {
156
+ $fb_shortcode['loadmore'] = 'button';
157
+ }
158
+ }
159
+
160
+ if ( ! is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && ! is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && ! is_plugin_active( 'feed-them-social-combined-streams/feed-them-social-combined-streams.php' ) && $fb_shortcode['posts'] > '6' ) {
161
+ $fb_shortcode['posts'] = '6';
162
+ }
163
+
164
+ // Get Access Token.
165
+ $access_token = isset( $fb_shortcode['access_token'] ) ? $fb_shortcode['access_token'] : '';
166
+ if ( ! empty( $access_token ) ) {
167
+ $access_token = $fb_shortcode['access_token'];
168
+ } else {
169
+ $access_token = $this->get_access_token();
170
+ }
171
+
172
+ // UserName?.
173
+ if ( ! $fb_shortcode['id'] ) {
174
+ return 'Please enter a username for this feed.';
175
+ }
176
+ if ( 'reviews' === $fb_shortcode['type'] && ! is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) ) {
177
+ return '<div style="clear:both; padding:15px 0;">You must have FTS Facebook Reviews extension active to see this feed.</div>';
178
+ }
179
+
180
+ $type = isset( $fb_shortcode['type'] ) ? $fb_shortcode['type'] : '';
181
+ if ( 'group' === $type || 'page' === $type || 'event' === $type ) {
182
+
183
+ // EMPTY FACEBOOK POSTS OFFSET AND COUNT.
184
+ // Option Now Being Removed from here and the Facebook Settings Page.
185
+ // Setting it to blank so no matter what it will never error get_option('fb_count_offset');.
186
+ $fb_count_offset = '';
187
+
188
+ // View Link.
189
+ $fts_view_fb_link = '';
190
+ // Get Cache Name.
191
+ $fb_cache_name = '';
192
+ // Get language.
193
+ $language = '';
194
+
195
+ // Get Response (AKA Page & Feed Information) ERROR CHECK inside this function.
196
+ $response2 = $this->get_facebook_feed_response( $fb_shortcode, $fb_cache_name, $access_token, $language );
197
+
198
+ // Test to see if the re-sort date option is working from function above.
199
+ // print $this->dateSort;.
200
+ $feed_data_check = json_decode( $response2['feed_data'] );
201
+
202
+ // SHOW THE REGULAR FEEDS PRINT_R
203
+ // echo '<pre>';
204
+ // print_r($feed_data_check);
205
+ // echo '</pre>';
206
+ // $idNew = array();
207
+ // $idNew = explode(',', $fb_shortcode['id']);
208
+ // Testing options before foreach loop
209
+ // $idNew = 'tonyhawk';
210
+ // print_r($feed_data_check->$idNew->data);.
211
+ if ( is_plugin_active( 'feed-them-social-combined-streams/feed-them-social-combined-streams.php' ) ) {
212
+ $fts_count_ids = substr_count( $fb_shortcode['id'], ',' );
213
+ } else {
214
+ $fts_count_ids = '';
215
+ }
216
+
217
+ if ( isset( $feed_data_check->data ) ) {
218
+ if ( $fts_count_ids >= 1 && 'reviews' !== $fb_shortcode['type'] ) {
219
+ $fts_list_arrays = array();
220
+ foreach ( $feed_data_check as $feed_data_name ) {
221
+
222
+ if ( isset( $feed_data_name->data ) ) {
223
+ $fts_list_arrays = array_merge_recursive( $fts_list_arrays, $feed_data_name->data );
224
+ }
225
+ // var_dump( $fts_list_arrays[$i]);.
226
+ }
227
+ $merged_array['data'] = $fts_list_arrays;
228
+ $feed_data_check = (object) $merged_array;
229
+ }
230
+
231
+ // Test the created dataes are being sorted properly
232
+ // foreach($merged_array['data'] as $newSort) {
233
+ // print date("jS F, Y", strtotime($newSort->created_time));
234
+ // print '<br/>';
235
+ // }.
236
+ $set_zero = 0;
237
+ foreach ( $feed_data_check->data as $post_count ) {
238
+
239
+ $fb_message = isset( $post_count->message ) ? $post_count->message : '';
240
+ $fb_story = isset( $post_count->story ) ? $post_count->story : '';
241
+ $fb_type = isset( $post_count->attachments->data[0]->type ) ? $post_count->attachments->data[0]->type : '';
242
+ $fb_status_type = isset( $post_count->status_type ) ? $post_count->status_type : '';
243
+
244
+ // This is the method to skip empty posts or posts that are simply about changing settings or other non important post types
245
+ // We will count all the ones that are like this and add that number to the output of posts to offset the posts we are filtering out. Line 278 needs the same treatment of if options.
246
+ if ( 'status' === $fb_type && empty( $fb_message ) && empty( $fb_story ) || 'event' === $fb_type || 'event' === $fb_type && false !== strpos( $fb_story, 'shared their event' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'changed the name of the event to' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'changed the privacy setting' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'an admin of the group' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'created the group' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'added an event' ) || 'event' === $fb_type && false !== strpos( $fb_story, 'added an event' ) ) {
247
+ $set_zero++;
248
+ } elseif ( '0' === $feed_data_check->data ) {
249
+ // If more than the 5 posts(default in free) or the post= from shortcode is set to the amount of posts that are being filtered above we will add 7 to the post count to try and get at some posts.
250
+ // This will only happen for Page and Group feeds.
251
+ $set_zero = '7';
252
+ }
253
+ }// END POST foreach.
254
+
255
+ // Result of the foreach loop above minus the empty posts and offset by those posts the actual number of posts entered is shown
256
+ // $fb_shortcode['posts'] = $result;.
257
+ if ( ! empty( $fb_count_offset ) ) {
258
+ $set_zero = $fb_count_offset;
259
+ $unset_count = $fb_shortcode['posts'] + $set_zero;
260
+ $fb_shortcode['posts'] = $unset_count;
261
+ } else {
262
+ $unset_count = $fb_shortcode['posts'] + $set_zero;
263
+ $fb_shortcode['posts'] = $unset_count;
264
+ }
265
+
266
+ // SHOW THE $feed_data_check PRINT_R
267
+ // echo '<pre>';
268
+ // print_r($feed_data_check);
269
+ // echo '</pre>, ';.
270
+ }
271
+ // END.
272
+ }
273
+
274
+ ob_start();
275
+ // Uncomment these for testing purposes to see the actual count and the offset count
276
+ // print $set_zero;
277
+ // print $fb_shortcode['posts'];
278
+ // print 'asdfasdfasdf<br/>';
279
+ // print $fb_type;
280
+ // View Link.
281
+ $fts_view_fb_link = $this->get_view_link( $fb_shortcode );
282
+ // Get Cache Name.
283
+ $fb_cache_name = $this->get_fb_cache_name( $fb_shortcode );
284
+ // Get language.
285
+ $language = $this->get_language( $fb_shortcode );
286
+ if ( 'reviews' !== $fb_shortcode['type'] ) {
287
+ // Get Response (AKA Page & Feed Information) ERROR CHECK inside this function.
288
+ $response = $this->get_facebook_feed_response( $fb_shortcode, $fb_cache_name, $access_token, $language );
289
+ // Json decode data and build it from cache or response.
290
+ $page_data = json_decode( $response['page_data'] );
291
+ $feed_data = json_decode( $response['feed_data'] );
292
+ }
293
+
294
+ if ( is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && true == get_option( 'fts_facebook_custom_api_token_biz' ) && 'reviews' === $fb_shortcode['type'] ||
295
+ is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && ! empty( $fb_shortcode['token'] ) && 'reviews' === $fb_shortcode['type'] ||
296
+ is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && ! empty( $fb_shortcode['access_token'] ) && 'reviews' === $fb_shortcode['type'] ) {
297
+
298
+ if ( 'yes' === $fb_shortcode['remove_reviews_no_description'] && ! isset( $_GET['load_more_ajaxing'] ) ) {
299
+
300
+ $fts_facebook_reviews = new FTS_Facebook_Reviews();
301
+ $no_description_count = $fts_facebook_reviews->review_count_check( $fb_shortcode );
302
+
303
+ // testing purposes
304
+ // print ''. $no_description_count - $fb_shortcode['posts'] .' = The amount of posts with no review text.';
305
+ // this count includes our original posts count + the amount of posts we found with no description.
306
+ $fb_shortcode['posts'] = $no_description_count;
307
+ }
308
+ if ( ! empty( $fb_shortcode['token'] ) ) {
309
+ $biz_access_token = $fb_shortcode['token'];
310
+ } elseif ( ! empty( $fb_shortcode['access_token'] ) ) {
311
+ $biz_access_token = $fb_shortcode['access_token'];
312
+ } else {
313
+ $biz_access_token = get_option( 'fts_facebook_custom_api_token_biz' );
314
+ }
315
+
316
+ // Get Response (AKA Page & Feed Information) ERROR CHECK inside this function.
317
+ $response = $this->get_facebook_feed_response( $fb_shortcode, $fb_cache_name, $biz_access_token, $language );
318
+
319
+ $feed_data = json_decode( $response['feed_data'] );
320
+
321
+ $feed_data = (object) $feed_data;
322
+ // Add Feed Type to post array.
323
+ // SHOW THE REVIEWS FEED PRINT_R
324
+ // echo '<pre>';
325
+ // print_r($feed_data );
326
+ // echo '</pre>';
327
+ if ( 'yes' === $fb_shortcode['remove_reviews_no_description'] ) {
328
+ // $no_description_count2 = 0;.
329
+ foreach ( $feed_data->data as $k => $v ) {
330
+ if ( ! isset( $v->review_text ) ) {
331
+ // print $v->reviewer->name . ' (Key# ' . $k . ') : Now Unset from array<br/>';.
332
+ unset( $feed_data->data[ $k ] );
333
+ // $no_description_count2++;.
334
+ }
335
+ }
336
+ }
337
+ $ratings_data = json_decode( $response['ratings_data'] );
338
+
339
+ // SHOW THE REVIEWS RATING INFO PRINT_R
340
+ // echo '<pre>';
341
+ // print_r($ratings_data );
342
+ // echo '</pre>';.
343
+ // Add fts_profile_pic_url to the array so we can show profile photos for reviews and comments in popup
344
+ foreach ( $feed_data->data as $post_array ) {
345
+
346
+ $the_image = 'https://graph.facebook.com/' . $post_array->reviewer->id . '/picture?redirect=false&access_token=' . $biz_access_token . '';
347
+
348
+ $profile_pic_response = wp_remote_get( $the_image );
349
+ $profile_pic_data = wp_remote_retrieve_body( $profile_pic_response );
350
+ $profile_pic_output = json_decode( $profile_pic_data );
351
+
352
+ // echo '<pre>';
353
+ // print_r($profile_pic_output->data->url);
354
+ // echo '</pre>';
355
+ $post_array->fts_profile_pic_url = $profile_pic_output->data->url;
356
+ }
357
+ }
358
+
359
+ if ( is_plugin_active( 'feed-them-social-combined-streams/feed-them-social-combined-streams.php' ) ) {
360
+ $fts_count_ids = substr_count( $fb_shortcode['id'], ',' );
361
+ } else {
362
+ $fts_count_ids = '';
363
+ }
364
+
365
+ if ( $fts_count_ids >= 1 && 'reviews' !== $fb_shortcode['type'] ) {
366
+
367
+ $fts_list_arrays = array();
368
+ foreach ( $feed_data as $feed_data_name ) {
369
+
370
+ $fts_list_arrays = array_merge_recursive( $fts_list_arrays, $feed_data_name->data );
371
+ // var_dump( $fts_list_arrays[$i]);.
372
+ }
373
+ // Sort the array using the call back function.
374
+ usort( $fts_list_arrays, array( $this, 'dateSort' ) );
375
+
376
+ $merged_array['data'] = $fts_list_arrays;
377
+ $feed_data = (object) $merged_array;
378
+ }
379
+ // SHOW THE REGULAR FEEDS PRINT_R (WORKS FOR VIDEOS AND ALBUMS TOO)
380
+ // echo '<pre>';
381
+ // print_r($feed_data );
382
+ // echo '</pre>';
383
+ // If No Response or Error then return.
384
+ if ( is_array( $response ) && isset( $response[0] ) && isset( $response[1] ) && false === $response[0] ) {
385
+ return $response[1];
386
+ }
387
+
388
+ if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) ) {
389
+ // Make sure it's not ajaxing and we will allow the omition of certain album covers from the list by using omit_album_covers=0,1,2,3 in the shortcode.
390
+ if ( ! isset( $_GET['load_more_ajaxing'] ) && 'albums' === $fb_shortcode['type'] ) {
391
+
392
+ // omit_album_covers=0,1,2,3 for example.
393
+ $omit_album_covers = $fb_shortcode['omit_album_covers'];
394
+ $omit_album_covers_new = array();
395
+ $omit_album_covers_new = explode( ',', $omit_album_covers );
396
+ foreach ( $feed_data->data as $post_data ) {
397
+ foreach ( $omit_album_covers_new as $omit ) {
398
+ unset( $feed_data->data[ $omit ] );
399
+ }
400
+ }
401
+ }
402
+ }
403
+ // Reviews Rating Filter.
404
+ if ( is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && 'reviews' === $fb_shortcode['type'] ) {
405
+ foreach ( $feed_data->data as $key => $post_data ) {
406
+ // we are not going to show the unrecommended reviews in the feed at this point, no options in our plugin srl 8-28-18.
407
+ if ( isset( $post_data->rating ) && $post_data->rating < $fb_shortcode['reviews_type_to_show'] || isset( $post_data->recommendation_type ) && 'negative' === $post_data->recommendation_type ) {
408
+ unset( $feed_data->data[ $key ] );
409
+ }
410
+ }
411
+ }
412
+
413
+ // Make sure it's not ajaxing.
414
+ if ( ! isset( $_GET['load_more_ajaxing'] ) ) {
415
+ // Get Response (AKA Page & Feed Information).
416
+ $_REQUEST['fts_dynamic_name'] = sanitize_key( $this->fts_rand_string( 10 ) . '_' . $fb_shortcode['type'] );
417
+ // Create Dynamic Class Name.
418
+ $fts_dynamic_class_name = $this->get_fts_dynamic_class_name();
419
+ // SOCIAL BUTTON.
420
+ if ( ! $fts_count_ids >= 1 ) {
421
+ $this->fb_social_btn_placement( $fb_shortcode, $access_token, 'fb-like-top-above-title' );
422
+ }
423
+
424
+ if ( 'reviews' !== $fb_shortcode['type'] ) {
425
+ $page_data->description = isset( $page_data->description ) ? $page_data->description : '';
426
+ $page_data->name = isset( $page_data->name ) ? $page_data->name : '';
427
+ }
428
+ // fts-fb-header-wrapper (for grid).
429
+ echo isset( $fb_shortcode['grid'] ) && 'yes' !== $fb_shortcode['grid'] && 'album_photos' !== $fb_shortcode['type'] && 'albums' !== $fb_shortcode['type'] ? '<div class="fts-fb-header-wrapper">' : '';
430
+
431
+ // Header.
432
+ echo '<div class="fts-jal-fb-header">';
433
+
434
+ if ( is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && isset( $fb_shortcode['overall_rating'] ) && 'yes' === $fb_shortcode['overall_rating'] ) {
435
+
436
+ // echo $this->get_facebook_overall_rating_response($fb_shortcode, $fb_cache_name, $access_token);.
437
+ $fb_reviews_overall_rating_of_5_stars_text = get_option( 'fb_reviews_overall_rating_of_5_stars_text' );
438
+ $fb_reviews_overall_rating_of_5_stars_text = ! empty( $fb_reviews_overall_rating_of_5_stars_text ) ? ' ' . $fb_reviews_overall_rating_of_5_stars_text : ' of 5 stars';
439
+ $fb_reviews_overall_rating_reviews_text = get_option( 'fb_reviews_overall_rating_reviews_text' );
440
+ $fb_reviews_overall_rating_reviews_text = ! empty( $fb_reviews_overall_rating_reviews_text ) ? ' ' . $fb_reviews_overall_rating_reviews_text : ' reviews';
441
+ $fb_reviews_overall_rating_background_border_hide = get_option( 'fb_reviews_overall_rating_background_border_hide' );
442
+ $fb_reviews_overall_rating_background_border_hide = ! empty( $fb_reviews_overall_rating_background_border_hide ) && 'yes' === $fb_reviews_overall_rating_background_border_hide ? ' fts-review-details-master-wrap-no-background-or-border' : '';
443
+ echo '<div class="fts-review-details-master-wrap' . esc_attr( $fb_reviews_overall_rating_background_border_hide ) . '" itemscope itemtype="http://schema.org/CreativeWork"><i class="fts-review-star">' . esc_html( $ratings_data->overall_star_rating ) . ' &#9733;</i>';
444
+ echo '<div class="fts-review-details-wrap" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"><div class="fts-review-details"><span itemprop="ratingValue">' . esc_html( $ratings_data->overall_star_rating ) . '</span>' . esc_html( $fb_reviews_overall_rating_of_5_stars_text ) . '</div>';
445
+ echo '<div class="fts-review-details-count"><span itemprop="reviewCount">' . esc_html( $ratings_data->rating_count ) . '</span>' . esc_html( $fb_reviews_overall_rating_reviews_text ) . '</div></div></div>';
446
+
447
+ }
448
+ if ( 'reviews' !== $fb_shortcode['type'] ) {
449
+
450
+ $fb_title_htag = get_option( 'fb_title_htag' ) ? get_option( 'fb_title_htag' ) : 'h1';
451
+
452
+ if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) ) {
453
+ // echo our Facebook Page Title or About Text. Commented out the group description because in the future we will be adding the about description.
454
+ $fb_title_htag_size = get_option( 'fb_title_htag_size' ) ? 'font-size:' . get_option( 'fb_title_htag_size' ) . ';' : '';
455
+ $fts_align_title = isset( $fb_shortcode['title_align'] ) && '' !== $fb_shortcode['title_align'] ? 'style=text-align:' . $fb_shortcode['title_align'] . ';' . $fb_title_htag_size . '' : $fb_title_htag_size;
456
+ echo isset( $fb_shortcode['title'] ) && 'no' !== $fb_shortcode['title'] ? '<' . esc_html( $fb_title_htag ) . ' ' . esc_attr( $fts_align_title ) . '><a href="' . esc_url( $fts_view_fb_link ) . '" target="_blank" rel="noreferrer">' . esc_html( $page_data->name ) . '</a></' . esc_html( $fb_title_htag ) . '>' : '';
457
+
458
+ } else {
459
+ // echo our Facebook Page Title or About Text. Commented out the group description because in the future we will be adding the about description.
460
+ $fb_title_htag_size = get_option( 'fb_title_htag_size' ) ? 'style=font-size:' . get_option( 'fb_title_htag_size' ) . ';' : '';
461
+ echo '<' . esc_html( $fb_title_htag ) . ' ' . esc_attr( $fb_title_htag_size ) . '><a href="' . esc_url( $fts_view_fb_link ) . '" target="_blank" rel="noreferrer">' . esc_html( $page_data->name ) . '</a></' . esc_html( $fb_title_htag ) . '>';
462
+ }
463
+ // Description.
464
+ echo isset( $fb_shortcode['description'] ) && 'no' !== $fb_shortcode['description'] ? '<div class="fts-jal-fb-group-header-desc">' . wp_kses(
465
+ $this->fts_facebook_tag_filter( $page_data->description ),
466
+ array(
467
+ 'a' => array(
468
+ 'href' => array(),
469
+ 'title' => array(),
470
+ ),
471
+ 'br' => array(),
472
+ 'em' => array(),
473
+ 'strong' => array(),
474
+ 'small' => array(),
475
+ )
476
+ ) . '</div>' : '';
477
+ }
478
+ // END Header.
479
+ echo '</div>';
480
+ // Close fts-fb-header-wrapper.
481
+ echo isset( $fb_shortcode['grid'] ) && 'yes' !== $fb_shortcode['grid'] && 'album_photos' !== $fb_shortcode['type'] && 'albums' !== $fb_shortcode['type'] ? '</div>' : '';
482
+ } //End check.
483
+
484
+ // SOCIAL BUTTON.
485
+ if ( ! $fts_count_ids >= 1 ) {
486
+ $this->fb_social_btn_placement( $fb_shortcode, $access_token, 'fb-like-top-below-title' );
487
+ }
488
+
489
+ // Feed Header.
490
+ // Make sure it's not ajaxing.
491
+ if ( ! isset( $_GET['load_more_ajaxing'] ) ) {
492
+
493
+ $fts_mashup_media_top = isset( $fb_shortcode['show_media'] ) && 'top' === $fb_shortcode['show_media'] ? 'fts-mashup-media-top ' : '';
494
+ $fts_mashup_show_name = isset( $fb_shortcode['show_name'] ) && 'no' === $fb_shortcode['show_name'] ? ' fts-mashup-hide-name ' : '';
495
+ $fts_mashup_show_date = isset( $fb_shortcode['show_date'] ) && 'no' === $fb_shortcode['show_date'] ? ' fts-mashup-hide-date ' : '';
496
+ $fts_mashup_show_thumbnail = isset( $fb_shortcode['show_thumbnail'] ) && 'no' === $fb_shortcode['show_thumbnail'] ? ' fts-mashup-hide-thumbnail ' : '';
497
+
498
+ if ( ! isset( $fb_type ) && 'albums' === $fb_shortcode['type'] || ! isset( $fb_type ) && 'album_photos' === $fb_shortcode['type'] || isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] ) {
499
+
500
+ if ( isset( $fb_shortcode['video_album'] ) && 'yes' === $fb_shortcode['video_album'] ) {
501
+ echo '';
502
+ } elseif ( isset( $fb_shortcode['slider'] ) && 'yes' !== $fb_shortcode['slider'] && 'yes' === $fb_shortcode['image_stack_animation'] || isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] || isset( $fb_shortcode['image_stack_animation'] ) && 'yes' === $fb_shortcode['image_stack_animation'] ) {
503
+ wp_enqueue_script( 'fts-masonry-pkgd', plugins_url( 'feed-them-social/feeds/js/masonry.pkgd.min.js' ), array( 'jquery' ), FTS_CURRENT_VERSION, false );
504
+ echo '<script>';
505
+ echo 'jQuery(window).on(\'load\', function(){';
506
+ echo 'jQuery(".' . esc_js( $fts_dynamic_class_name ) . '").masonry({';
507
+ echo 'itemSelector: ".fts-jal-single-fb-post"';
508
+ echo '});';
509
+ echo '});';
510
+ echo '</script>';
511
+ }
512
+
513
+ if ( ! isset( $fb_type ) && 'albums' === $fb_shortcode['type'] || ! isset( $fb_type ) && 'album_photos' === $fb_shortcode['type'] && ! isset( $fb_type ) && ! isset( $fb_shortcode['slider'] ) || ! isset( $fb_type ) && 'album_photos' === $fb_shortcode['type'] && ! isset( $fb_type ) && isset( $fb_shortcode['slider'] ) && 'yes' !== $fb_shortcode['slider'] ) {
514
+ echo '<div class="fts-slicker-facebook-photos fts-slicker-facebook-albums' . ( isset( $fb_shortcode['video_album'] ) && $fb_shortcode['video_album'] && 'yes' === $fb_shortcode['video_album'] ? ' popup-video-gallery-fb' : '' ) . ( isset( $fb_shortcode['image_stack_animation'] ) && 'yes' === $fb_shortcode['image_stack_animation'] ? ' masonry js-masonry' : '' ) . ( isset( $fb_shortcode['images_align'] ) && $fb_shortcode['images_align'] ? ' popup-video-gallery-align-' . esc_attr( $fb_shortcode['images_align'] ) : '' ) . ' popup-gallery-fb ' . esc_attr( $fts_dynamic_class_name ) . '"';
515
+ if ( 'yes' === $fb_shortcode['image_stack_animation'] ) {
516
+ echo 'data-masonry-options=\'{ "isFitWidth": ' . ( 'no' === $fb_shortcode['center_container'] ? 'false' : 'true' ) . ' ' . ( 'no' === $fb_shortcode['image_stack_animation'] ? ', "transitionDuration": 0' : '' ) . '}\' style="margin:auto;"';
517
+ }
518
+ echo '>';
519
+ } elseif (
520
+ // slideshow scrollHorz or carousel.
521
+ ! isset( $fb_type ) && isset( $fb_shortcode['slider'] ) && 'yes' === $fb_shortcode['slider'] ) {
522
+ $fts_cycle_type = isset( $fb_shortcode['scrollhorz_or_carousel'] ) ? $fb_shortcode['scrollhorz_or_carousel'] : 'scrollHorz';
523
+
524
+ if ( isset( $fts_cycle_type ) && 'carousel' === $fts_cycle_type ) {
525
+ $fts_cycle_slideshow = 'slideshow';
526
+ } else {
527
+ $fts_cycle_slideshow = 'cycle-slideshow';
528
+ }
529
+ echo '';
530
+
531
+ // none
532
+ // dots_above_feed
533
+ // dots_and_arrows_above_feed
534
+ // dots_and_numbers_above_feed
535
+ // dots_arrows_and_numbers_above_feed
536
+ // arrows_and_numbers_above_feed
537
+ // arrows_above_feed
538
+ // numbers_above_feed
539
+ // dots_below_feed
540
+ // dots_and_arrows_below_feed
541
+ // dots_and_numbers_below_feed
542
+ // dots_arrows_and_numbers_below_feed
543
+ // arrows_and_numbers_below_feed
544
+ // arrows_below_feed
545
+ // numbers_below_feed.
546
+ $fts_controls_bar_color = ! empty( $fb_shortcode['slider_controls_bar_color'] ) ? $fb_shortcode['slider_controls_bar_color'] : '#000';
547
+ $fts_controls_text_color = ! empty( $fb_shortcode['slider_controls_text_color'] ) ? $fb_shortcode['slider_controls_text_color'] : '#ddd';
548
+ if ( isset( $fb_shortcode['slider_controls_width'] ) && 'carousel' !== $fb_shortcode['scrollhorz_or_carousel'] ) {
549
+ $max_width_set = isset( $fb_shortcode['image_width'] ) && '' !== $fb_shortcode['image_width'] && 'carousel' !== $fb_shortcode['scrollhorz_or_carousel'] ? $fb_shortcode['image_width'] : '100%';
550
+ } else {
551
+ $max_width_set = isset( $fb_shortcode['slider_controls_width'] ) && '' !== $fb_shortcode['slider_controls_width'] && 'carousel' === $fb_shortcode['scrollhorz_or_carousel'] ? $fb_shortcode['slider_controls_width'] : '100%';
552
+ }
553
+ if (
554
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_above_feed' === $fb_shortcode['slider_controls'] ||
555
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_above_feed' === $fb_shortcode['slider_controls'] ||
556
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
557
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
558
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
559
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_above_feed' === $fb_shortcode['slider_controls'] ||
560
+ isset( $fb_shortcode['slider_controls'] ) && 'numbers_above_feed' === $fb_shortcode['slider_controls']
561
+ ) {
562
+
563
+ // Slider Dots Wrapper.
564
+ if (
565
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_above_feed' === $fb_shortcode['slider_controls'] ||
566
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_above_feed' === $fb_shortcode['slider_controls'] ||
567
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
568
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls']
569
+ ) {
570
+
571
+ echo '<div class="fts-slider-icons-center fts-pager-option-dots-only-top" style="margin:auto; width:100%;max-width:' . esc_attr( $max_width_set . ';background:' . $fts_controls_bar_color . ';color:' . $fts_controls_text_color ) . '"><div class="fts-pager-option fts-custom-pager-' . esc_attr( $fts_dynamic_class_name ) . '"></div></div>';
572
+ }
573
+
574
+ // Slider Arrow and Numbers Wrapper.
575
+ if (
576
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_above_feed' === $fb_shortcode['slider_controls'] ||
577
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
578
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
579
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
580
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_above_feed' === $fb_shortcode['slider_controls'] ||
581
+ isset( $fb_shortcode['slider_controls'] ) && 'numbers_above_feed' === $fb_shortcode['slider_controls']
582
+ ) {
583
+ echo '<div class="fts-slider-center" style="margin:auto; width:100%; max-width:' . esc_attr( $max_width_set . ';background:' . $fts_controls_bar_color . ';color:' . $fts_controls_text_color ) . '">';
584
+ }
585
+
586
+ // Previous Arrow.
587
+ if (
588
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_above_feed' === $fb_shortcode['slider_controls'] ||
589
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
590
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
591
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_above_feed' === $fb_shortcode['slider_controls']
592
+ ) {
593
+ echo '<span class="fts-prevControl-icon fts-prevControl-' . esc_attr( $fts_dynamic_class_name ) . '"></span>';
594
+ }
595
+ // Numbers.
596
+ if (
597
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
598
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
599
+ isset( $fb_shortcode['slider_controls'] ) && 'numbers_above_feed' === $fb_shortcode['slider_controls'] ||
600
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_above_feed' === $fb_shortcode['slider_controls']
601
+ ) {
602
+ echo '<span id="fts-custom-caption-' . esc_attr( $fts_dynamic_class_name ) . '" class="fts-custom-caption" ></span>';
603
+ }
604
+ // Next Arrow.
605
+ if (
606
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_above_feed' === $fb_shortcode['slider_controls'] ||
607
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
608
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
609
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_above_feed' === $fb_shortcode['slider_controls']
610
+ ) {
611
+ echo '<span class="fts-nextControl-icon fts-nextControl-' . esc_attr( $fts_dynamic_class_name ) . '"></span>';
612
+ }
613
+
614
+ // Slider Arrow and Numbers Wrapper.
615
+ if (
616
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_above_feed' === $fb_shortcode['slider_controls'] ||
617
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
618
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
619
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_above_feed' === $fb_shortcode['slider_controls'] ||
620
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_above_feed' === $fb_shortcode['slider_controls'] ||
621
+ isset( $fb_shortcode['slider_controls'] ) && 'numbers_above_feed' === $fb_shortcode['slider_controls']
622
+ ) {
623
+ echo '</div>';
624
+ }
625
+ }
626
+
627
+ echo '<div class="popup-gallery-fb fts-fb-slideshow fts-slicker-facebook-photos fts-slicker-facebook-albums ' . esc_attr( $fts_cycle_slideshow ) . ' ' . ( isset( $fb_shortcode['video_album'] ) && $fb_shortcode['video_album'] && 'yes' === $fb_shortcode['video_album'] ? 'popup-video-gallery-fb' : '' ) . ' ' . ( isset( $fb_shortcode['images_align'] ) && $fb_shortcode['images_align'] ? ' popup-video-gallery-align-' . esc_attr( $fb_shortcode['images_align'] ) : '' ) . ' popup-gallery-fb ' . esc_attr( $fts_dynamic_class_name ) . '"
628
 
629
  style="margin:' . ( isset( $fb_shortcode['slider_margin'] ) && '' !== $fb_shortcode['slider_margin'] ? esc_attr( $fb_shortcode['slider_margin'] ) : 'auto' ) . ';' . ( isset( $fts_cycle_type ) && 'carousel' === $fts_cycle_type ? 'width:100%; max-width:100%; overflow:hidden;height:' . esc_attr( $fb_shortcode['image_height'] ) . ';' : 'overflow:hidden; height:' . esc_attr( $fb_shortcode['image_height'] ) . '; max-width:' . ( isset( $fb_shortcode['image_width'] ) && '' !== $fb_shortcode['image_width'] ? esc_attr( $fb_shortcode['image_width'] ) : 'auto' ) ) . ';" data-cycle-caption="#fts-custom-caption-' . esc_attr( $fts_dynamic_class_name ) . '" data-cycle-caption-template="{{slideNum}} / {{slideCount}}" data-cycle-pager=".fts-custom-pager-' . esc_attr( $fts_dynamic_class_name ) . '" data-cycle-pause-on-hover="true" data-cycle-prev=".fts-prevControl-' . esc_attr( $fts_dynamic_class_name ) . '" data-cycle-next=".fts-nextControl-' . esc_attr( $fts_dynamic_class_name ) . '" data-cycle-timeout="' . ( ! empty( $fb_shortcode['slider_timeout'] ) ? esc_attr( $fb_shortcode['slider_timeout'] ) : '0' ) . '" data-cycle-manual-speed="' . ( ! empty( $fb_shortcode['slider_speed'] ) ? esc_attr( $fb_shortcode['slider_speed'] ) : '400' ) . '" data-cycle-auto-height="false" data-cycle-slides="> div" data-cycle-fx="' . ( ! empty( $fb_shortcode['scrollhorz_or_carousel'] ) ? esc_attr( $fb_shortcode['scrollhorz_or_carousel'] ) : '' ) . '" data-cycle-carousel-visible=' . ( ! empty( $fb_shortcode['slides_visible'] ) ? esc_attr( $fb_shortcode['slides_visible'] ) : '4' ) . ' data-cycle-swipe=true data-cycle-swipe-fx=' . ( ! empty( $fb_shortcode['scrollhorz_or_carousel'] ) ? esc_attr( $fb_shortcode['scrollhorz_or_carousel'] ) : '' ) . '>';
630
+ }
631
+
632
+ if ( isset( $fb_shortcode['grid'] ) && 'yes' === $fb_shortcode['grid'] ) {
633
+ echo '<div class="fts-slicker-facebook-posts masonry js-masonry ' . esc_attr( $fts_mashup_media_top . $fts_mashup_show_name . $fts_mashup_show_date . $fts_mashup_show_thumbnail ) . ( 'yes' === $fb_shortcode['popup'] ? 'popup-gallery-fb-posts ' : '' ) . ( 'reviews' === $fb_shortcode['type'] ? 'fts-reviews-feed ' : '' ) . esc_attr( $fts_dynamic_class_name ) . ' " style="margin:auto;" data-masonry-options=\'{ "isFitWidth": ' . ( 'no' === $fb_shortcode['center_container'] ? 'false' : 'true' ) . ' ' . ( 'no' === $fb_shortcode['image_stack_animation'] ? ', "transitionDuration": 0' : '' ) . '}\'>';
634
+ }
635
+ } else {
636
+ echo '<div class="fts-jal-fb-group-display fts-simple-fb-wrapper ' . esc_attr( $fts_mashup_media_top . $fts_mashup_show_name . $fts_mashup_show_date . $fts_mashup_show_thumbnail ) . ( isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ? ' popup-gallery-fb-posts ' : '' ) . ( 'reviews' === $fb_shortcode['type'] ? 'fts-reviews-feed ' : '' ) . esc_attr( $fts_dynamic_class_name ) . ' ' . ( 'auto' !== $fb_shortcode['height'] && ! empty( $fb_shortcode['height'] ) ? 'fts-fb-scrollable" style="height:' . esc_attr( $fb_shortcode['height'] ) . '"' : '"' ) . '>';
637
+ }
638
+ } //End ajaxing Check
639
+
640
+ // *********************
641
+ // Post Information
642
+ // *********************
643
+ $fb_load_more_text = get_option( 'fb_load_more_text' ) ? get_option( 'fb_load_more_text' ) : esc_html( 'Load More', 'feed-them-social' );
644
+ $response_post_array = $this->get_post_info( $feed_data, $fb_shortcode, $access_token, $language, $fb_cache_name );
645
+
646
+ // Single event info call.
647
+ if ( 'events' === $fb_shortcode['type'] ) {
648
+ $single_event_array_response = $this->get_event_post_info( $feed_data, $fb_shortcode, $access_token, $language );
649
+ }
650
+
651
+ $set_zero = 0;
652
+
653
+ // echo '<br/><br/>feed array<br/><br/>';.
654
+ // echo '<pre>';
655
+ // print_r($feed_data );
656
+ // echo '</pre>';.
657
+ // THE MAIN FEED
658
+ // LOOP to fix Post count!
659
+ foreach ( $feed_data->data as $k => $v ) {
660
+ if ( $k >= $fb_shortcode['posts'] ) {
661
+ unset( $feed_data->data[ $k ] );
662
+ }
663
+ }
664
+
665
+ // Nov. 4th. 2016 // Uncomment this to sort the dates proper if facebook is returning them out of order.
666
+ // We had one case of this here for a list of posts coming from an event.
667
+ // https://wordpress.org/support/topic/facebook-event-posts-not-ordered-by-date/
668
+ // usort($feed_data->data, array($this, "dateSort"));
669
+ // Loop for all facebook feeds.
670
+ foreach ( $feed_data->data as $post_data ) {
671
+
672
+ $fb_message = isset( $post_data->message ) ? $post_data->message : '';
673
+ $fb_status_type = isset( $post_data->status_type ) ? $post_data->status_type : '';
674
+
675
+ $fb_story = isset( $post_data->story ) ? $post_data->story : '';
676
+
677
+ if( 'albums' === $fb_shortcode['type'] ){
678
+ $fb_type = isset( $post_data->type ) ? $post_data->type : '';
679
+ }
680
+ else {
681
+ $fb_type = isset( $post_data->attachments->data[0]->type ) ? $post_data->attachments->data[0]->type : '';
682
+ }
683
+
684
+ // This is the method to skip empty posts or posts that are simply about changing settings or other non important post types.
685
+ if ( 'status' === $fb_type && empty( $fb_message ) && empty( $fb_story ) || 'event' === $fb_type || 'event' === $fb_type && false !== strpos( $fb_story, 'shared their event' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'changed the name of the event to' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'changed the privacy setting' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'an admin of the group' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'created the group' ) || 'status' === $fb_type && false !== strpos( $fb_story, 'added an event' ) || 'event' === $fb_type && false !== strpos( $fb_story, 'added an event' ) ) {
686
+ } else {
687
+ // define type note also affects load more fucntion call.
688
+ if ( ! $fb_type && 'album_photos' === $fb_shortcode['type'] ) {
689
+ $fb_type = 'photo';
690
+ }
691
+ if ( ! $fb_type && 'events' === $fb_shortcode['type'] ) {
692
+ $fb_type = 'events';
693
+
694
+ }
695
+
696
+ $post_types = new fts_facebook_feed_post_types();
697
+ $single_event_array_response = isset( $single_event_array_response ) ? $single_event_array_response : '';
698
+
699
+ // echo '<br/><br/>were function gets called <br/><br/>' .
700
+ // print_r( $post_data );.
701
+ $post_types->feed_post_types( $set_zero, $fb_type, $post_data, $fb_shortcode, $response_post_array, $single_event_array_response );
702
+
703
+ }
704
+
705
+ $set_zero++;
706
+ }// END POST foreach
707
+
708
+ if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && 'reviews' !== $fb_shortcode['type'] || is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && 'reviews' === $fb_shortcode['type'] ) {
709
+ if ( ! empty( $feed_data->data ) ) {
710
+ $this->fts_facebook_loadmore( $atts, $feed_data, $fb_type, $fb_shortcode, sanitize_key( $_REQUEST['fts_dynamic_name'] ) );
711
+ }
712
+ }
713
+
714
+ echo '</div>'; // closing main div for fb photos, groups etc
715
+ // only show this script if the height option is set to a number.
716
+ if ( 'auto' !== $fb_shortcode['height'] && ! empty( $fb_shortcode['height'] ) ) {
717
+ echo '<script>';
718
+ // this makes it so the page does not scroll if you reach the end of scroll bar or go back to top'.
719
+ echo 'jQuery.fn.isolatedScrollFacebookFTS = function() {';
720
+ echo 'this.bind("mousewheel DOMMouseScroll", function (e) {';
721
+ echo 'var delta = e.wheelDelta || (e.originalEvent && e.originalEvent.wheelDelta) || -e.detail,';
722
+ echo 'bottomOverflow = this.scrollTop + jQuery(this).outerHeight() - this.scrollHeight >= 0,';
723
+ echo 'topOverflow = this.scrollTop <= 0;';
724
+ echo 'if ((delta < 0 && bottomOverflow) || (delta > 0 && topOverflow)) {';
725
+ echo 'e.preventDefault();';
726
+ echo '}';
727
+ echo '});';
728
+ echo 'return this;';
729
+ echo '};';
730
+ echo 'jQuery(".fts-fb-scrollable").isolatedScrollFacebookFTS();';
731
+ echo '</script>';
732
+ } //end $fb_shortcode['height'] !== 'auto' && empty($fb_shortcode['height']) == NULL
733
+ // Make sure it's not ajaxing.
734
+ if ( ! isset( $_GET['load_more_ajaxing'] ) ) {
735
+ echo '<div class="fts-clear"></div><div id="fb-root"></div>';
736
+ if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && 'reviews' !== $fb_shortcode['type'] || is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && 'reviews' === $fb_shortcode['type'] ) {
737
+ if ( 'button' === $fb_shortcode['loadmore'] ) {
738
+
739
+ echo '<div class="fts-fb-load-more-wrapper">';
740
+ echo '<div id="loadMore_' . esc_attr( $_REQUEST['fts_dynamic_name'] ) . '" style="';
741
+ if ( isset( $fb_shortcode['loadmore_btn_maxwidth'] ) && '' !== $fb_shortcode['loadmore_btn_maxwidth'] ) {
742
+ echo 'max-width:' . esc_attr( $fb_shortcode['loadmore_btn_maxwidth'] ) . ';';
743
+ }
744
+ $loadmore_btn_margin = isset( $fb_shortcode['loadmore_btn_margin'] ) ? $fb_shortcode['loadmore_btn_margin'] : '20px';
745
+ echo 'margin:' . esc_attr( $loadmore_btn_margin ) . ' auto ' . esc_attr( $loadmore_btn_margin ) . '" class="fts-fb-load-more">' . esc_html( $fb_load_more_text ) . '</div>';
746
+ echo '</div>';
747
+ }
748
+ }
749
+ }//End Check
750
+
751
+ // Checks for sliders.
752
+ if (
753
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_below_feed' === $fb_shortcode['slider_controls'] ||
754
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_below_feed' === $fb_shortcode['slider_controls'] ||
755
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
756
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
757
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
758
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_below_feed' === $fb_shortcode['slider_controls'] ||
759
+ isset( $fb_shortcode['slider_controls'] ) && 'numbers_below_feed' === $fb_shortcode['slider_controls']
760
+ ) {
761
+
762
+ // Slider Dots Wrapper.
763
+ if (
764
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_below_feed' === $fb_shortcode['slider_controls'] ||
765
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_below_feed' === $fb_shortcode['slider_controls'] ||
766
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
767
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls']
768
+ ) {
769
+ if ( isset( $fb_shortcode['slider_controls_width'] ) && 'carousel' !== $fb_shortcode['scrollhorz_or_carousel'] ) {
770
+ $max_width_set = isset( $fb_shortcode['image_width'] ) && '' !== $fb_shortcode['image_width'] && 'carousel' !== $fb_shortcode['scrollhorz_or_carousel'] ? $fb_shortcode['image_width'] : '100%';
771
+ } else {
772
+ $max_width_set = isset( $fb_shortcode['slider_controls_width'] ) && '' !== $fb_shortcode['slider_controls_width'] && 'carousel' === $fb_shortcode['scrollhorz_or_carousel'] ? $fb_shortcode['slider_controls_width'] : '100%';
773
+ }
774
+
775
+ echo '<div class="fts-slider-icons-center" style="margin:auto; width:100%;max-width:' . esc_attr( $max_width_set ) . ';background:' . esc_attr( $fts_controls_bar_color ) . ';color:' . esc_attr( $fts_controls_text_color ) . '"><div class="fts-pager-option fts-custom-pager-' . esc_attr( $fts_dynamic_class_name ) . '"></div></div>';
776
+ }
777
+
778
+ // Slider Arrow and Numbers Wrapper.
779
+ if (
780
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_below_feed' === $fb_shortcode['slider_controls'] ||
781
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
782
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
783
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
784
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_below_feed' === $fb_shortcode['slider_controls'] ||
785
+ isset( $fb_shortcode['slider_controls'] ) && 'numbers_below_feed' === $fb_shortcode['slider_controls']
786
+ ) {
787
+ echo '<div class="fts-slider-center" style="margin:auto; width:100%; max-width:' . esc_attr( $max_width_set ) . ';background:' . esc_attr( $fts_controls_bar_color ) . ';color:' . esc_attr( $fts_controls_text_color ) . '">';
788
+ }
789
+
790
+ // Previous Arrow.
791
+ if (
792
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_below_feed' === $fb_shortcode['slider_controls'] ||
793
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
794
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
795
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_below_feed' === $fb_shortcode['slider_controls']
796
+ ) {
797
+ echo '<span class="fts-prevControl-icon fts-prevControl-' . esc_attr( $fts_dynamic_class_name ) . '"></span>';
798
+ }
799
+ // Numbers.
800
+ if (
801
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
802
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
803
+ isset( $fb_shortcode['slider_controls'] ) && 'numbers_below_feed' === $fb_shortcode['slider_controls'] ||
804
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_below_feed' === $fb_shortcode['slider_controls']
805
+ ) {
806
+ echo '<span id="fts-custom-caption-' . esc_attr( $fts_dynamic_class_name ) . '" class="fts-custom-caption" ></span>';
807
+ }
808
+ // Next Arrow.
809
+ if (
810
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_below_feed' === $fb_shortcode['slider_controls'] ||
811
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
812
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
813
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_below_feed' === $fb_shortcode['slider_controls']
814
+ ) {
815
+ echo '<span class="fts-nextControl-icon fts-nextControl-' . esc_attr( $fts_dynamic_class_name ) . '"></span>';
816
+ }
817
+
818
+ // Slider Arrow and Numbers Wrapper.
819
+ if (
820
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_arrows_below_feed' === $fb_shortcode['slider_controls'] ||
821
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
822
+ isset( $fb_shortcode['slider_controls'] ) && 'dots_arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
823
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_and_numbers_below_feed' === $fb_shortcode['slider_controls'] ||
824
+ isset( $fb_shortcode['slider_controls'] ) && 'arrows_below_feed' === $fb_shortcode['slider_controls'] ||
825
+ isset( $fb_shortcode['slider_controls'] ) && 'numbers_below_feed' === $fb_shortcode['slider_controls']
826
+ ) {
827
+ echo '</div>';
828
+ }
829
+ }
830
+
831
+ unset( $_REQUEST['next_url'] );
832
+
833
+ // ******************
834
+ // SOCIAL BUTTON
835
+ // ******************
836
+ if ( ! $fts_count_ids >= 1 ) {
837
+ $this->fb_social_btn_placement( $fb_shortcode, $access_token, 'fb-like-below' );
838
+ }
839
+
840
+ return ob_get_clean();
841
+ }
842
+
843
+ /**
844
+ * Get FTS Dnamic Class Name
845
+ *
846
+ * @return string
847
+ * @since 1.9.6
848
+ */
849
+ public function get_fts_dynamic_class_name() {
850
+ $fts_dynamic_class_name = '';
851
+ if ( isset( $_REQUEST['fts_dynamic_name'] ) ) {
852
+ $fts_dynamic_class_name = 'feed_dynamic_class' . sanitize_key( $_REQUEST['fts_dynamic_name'] );
853
+ }
854
+ return $fts_dynamic_class_name;
855
+ }
856
+
857
+ /**
858
+ * FTS Facebook Location
859
+ *
860
+ * Facebook Post Location.
861
+ *
862
+ * @param null $fb_type What kind of facebook feed it is.
863
+ * @param string $location The location of the photo or video.
864
+ * @since 1.9.6
865
+ */
866
+ public function fts_facebook_location( $fb_type = null, $location ) {
867
+ switch ( $fb_type ) {
868
+ case 'app':
869
+ case 'cover':
870
+ case 'profile':
871
+ case 'mobile':
872
+ case 'wall':
873
+ case 'normal':
874
+ case 'album':
875
+ echo '<div class="fts-fb-location">' . esc_html( $location ) . '</div>';
876
+ }
877
+ }
878
+
879
+ /**
880
+ * FTS Facebook Post Photo
881
+ *
882
+ * @param string $fb_link The link to post.
883
+ * @param string $fb_shortcode The shortcode.
884
+ * @param string $photo_from Who it's from.
885
+ * @param string $photo_source The source url.
886
+ * @since 1.9.6
887
+ */
888
+ public function fts_facebook_post_photo( $fb_link, $fb_shortcode, $photo_from, $photo_source ) {
889
+ if ( 'album_photos' === $fb_shortcode['type'] || 'albums' === $fb_shortcode['type'] ) {
890
+ echo '<a href="' . esc_url( $fb_link ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-picture album-photo-fts" style="width:' . esc_attr( $fb_shortcode['image_width'] . ';height:' . $fb_shortcode['image_height'] ) . ';';
891
+ echo 'background-image:url(' . esc_url( $photo_source ) . ');">';
892
+ echo '</a>';
893
+ } else {
894
+ $fb_shortcode_popup = isset( $fb_shortcode['popup'] ) ? $fb_shortcode['popup'] : '';
895
+ if ( 'yes' === $fb_shortcode_popup && 'javascript:;' !== $fb_link ) {
896
+ echo '<a href="' . esc_url( $photo_source ) . '" target="_blank" rel="noreferrer" class="fts-facebook-link-target fts-jal-fb-picture fts-fb-large-photo"><img border="0" alt="' . esc_html( $photo_from ) . '" src="' . esc_url( $photo_source ) . '"/></a>';
897
+
898
+ } else {
899
+ echo '<a href="' . esc_url( $fb_link ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-picture"><img border="0" alt="' . esc_html( $photo_from ) . '" src="' . esc_url( $photo_source ) . '"/></a>';
900
+ }
901
+ }
902
+ }
903
+
904
+ /**
905
+ * FTS Facebook Post Name
906
+ *
907
+ * @param string $fb_link The post link.
908
+ * @param string $fb_name The facebook name.
909
+ * @param string $fb_type The type of feed.
910
+ * @param null $fb_post_id The facebook post ID.
911
+ * @since 1.9.6
912
+ */
913
+ public function fts_facebook_post_name( $fb_link, $fb_name, $fb_type, $fb_post_id = null ) {
914
+
915
+ switch ( $fb_type ) {
916
+ case 'video_direct_response' :
917
+ case 'video_inline' :
918
+ echo '<a href="' . esc_url( $fb_link ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-name fb-id' . esc_attr( $fb_post_id ) . '">' . wp_kses(
919
+ $this->fts_facebook_tag_filter( $fb_name ),
920
+ array(
921
+ 'a' => array(
922
+ 'href' => array(),
923
+ 'title' => array(),
924
+ ),
925
+ 'br' => array(),
926
+ 'em' => array(),
927
+ 'strong' => array(),
928
+ 'small' => array(),
929
+ )
930
+ ) . '</a>';
931
+ break;
932
+ default:
933
+ $fb_name = $this->fts_facebook_tag_filter( $fb_name );
934
+ echo '<a href="' . esc_url( $fb_link ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-name">' . wp_kses(
935
+ $this->fts_facebook_tag_filter( $fb_name ),
936
+ array(
937
+ 'a' => array(
938
+ 'href' => array(),
939
+ 'title' => array(),
940
+ ),
941
+ 'br' => array(),
942
+ 'em' => array(),
943
+ 'strong' => array(),
944
+ 'small' => array(),
945
+ )
946
+ ) . '</a>';
947
+ break;
948
+ }
949
+ }
950
+
951
+ /**
952
+ * FTS Facebook Post Description
953
+ *
954
+ * @param string $fb_description The post description.
955
+ * @param string $fb_shortcode The shortcode.
956
+ * @param string $fb_type The type of feed.
957
+ * @param null $fb_post_id The post ID.
958
+ * @param null $fb_by The post by.
959
+ * @since 1.9.6
960
+ */
961
+ public function fts_facebook_post_desc( $fb_description, $fb_shortcode, $fb_type, $fb_post_id = null, $fb_by = null ) {
962
+ $trunacate_words = new \FeedThemSocialTruncateHTML();
963
+
964
+ $fb_description = $this->fts_facebook_tag_filter( $fb_description );
965
+ $more = isset( $more ) ? $more : '...';
966
+
967
+ switch ( $fb_type ) {
968
+ case 'video_direct_response' :
969
+ case 'video_inline' :
970
+ echo '<div class="fts-jal-fb-description fb-id' . esc_attr( $fb_post_id ) . '">' . wp_kses(
971
+ nl2br( $fb_description ),
972
+ array(
973
+ 'a' => array(
974
+ 'href' => array(),
975
+ 'title' => array(),
976
+ ),
977
+ 'br' => array(),
978
+ 'em' => array(),
979
+ 'strong' => array(),
980
+ 'small' => array(),
981
+ )
982
+ ) . '</div>';
983
+ break;
984
+ case 'photo':
985
+ if ( 'album_photos' === $fb_shortcode['type'] ) {
986
+ if ( array_key_exists( 'words', $fb_shortcode ) ) {
987
+ $trimmed_content = $trunacate_words->fts_custom_trim_words( $fb_description, $fb_shortcode['words'], $more );
988
+ echo '<div class="fts-jal-fb-description fts-non-popup-text">' . wp_kses(
989
+ nl2br( $trimmed_content ),
990
+ array(
991
+ 'a' => array(
992
+ 'href' => array(),
993
+ 'title' => array(),
994
+ ),
995
+ 'br' => array(),
996
+ 'em' => array(),
997
+ 'strong' => array(),
998
+ 'small' => array(),
999
+ )
1000
+ ) . '</div>';
1001
+ // Here we display the full description in the popup.
1002
+ if ( 'yes' === $fb_shortcode['popup'] || 'yes' === $fb_shortcode['video_album'] ) {
1003
+ echo '<div class="fts-jal-fb-description fts-jal-fb-description-popup" style="display: none;">' . wp_kses(
1004
+ nl2br( $fb_description ),
1005
+ array(
1006
+ 'a' => array(
1007
+ 'href' => array(),
1008
+ 'title' => array(),
1009
+ ),
1010
+ 'br' => array(),
1011
+ 'em' => array(),
1012
+ 'strong' => array(),
1013
+ 'small' => array(),
1014
+ )
1015
+ ) . '</div>';
1016
+ }
1017
+ } elseif ( isset( $fb_shortcode['words'] ) && '0' !== $fb_shortcode['words'] ) {
1018
+ echo '<div class="fts-jal-fb-description">' . wp_kses(
1019
+ nl2br( $fb_description ),
1020
+ array(
1021
+ 'a' => array(
1022
+ 'href' => array(),
1023
+ 'title' => array(),
1024
+ ),
1025
+ 'br' => array(),
1026
+ 'em' => array(),
1027
+ 'strong' => array(),
1028
+ 'small' => array(),
1029
+ )
1030
+ ) . '</div>';
1031
+ }
1032
+ }
1033
+ break;
1034
+ case 'albums':
1035
+ if ( 'albums' === $fb_shortcode['type'] ) {
1036
+ if ( array_key_exists( 'words', $fb_shortcode ) ) {
1037
+ $trimmed_content = $trunacate_words->fts_custom_trim_words( $fb_description, $fb_shortcode['words'], $more );
1038
+ echo '<div class="fts-jal-fb-description">' . wp_kses(
1039
+ nl2br( $trimmed_content ),
1040
+ array(
1041
+ 'a' => array(
1042
+ 'href' => array(),
1043
+ 'title' => array(),
1044
+ ),
1045
+ 'br' => array(),
1046
+ 'em' => array(),
1047
+ 'strong' => array(),
1048
+ 'small' => array(),
1049
+ )
1050
+ ) . '</div>';
1051
+ } else {
1052
+ echo '<div class="fts-jal-fb-description">' . wp_kses(
1053
+ nl2br( $fb_description ),
1054
+ array(
1055
+ 'a' => array(
1056
+ 'href' => array(),
1057
+ 'title' => array(),
1058
+ ),
1059
+ 'br' => array(),
1060
+ 'em' => array(),
1061
+ 'strong' => array(),
1062
+ 'small' => array(),
1063
+ )
1064
+ ) . '</div>';
1065
+ }
1066
+ } else {
1067
+ // Do for Default feeds or the video gallery feed.
1068
+ if ( isset( $fb_shortcode['words'] ) && '0' !== $fb_shortcode['words'] ) {
1069
+ if ( is_array( $fb_shortcode ) && array_key_exists( 'words', $fb_shortcode ) && '0' !== $fb_shortcode['words'] ) {
1070
+ $trimmed_content = $trunacate_words->fts_custom_trim_words( $fb_description, $fb_shortcode['words'], $more );
1071
+ echo '<div class="fts-jal-fb-description">' . wp_kses(
1072
+ $trimmed_content,
1073
+ array(
1074
+ 'a' => array(
1075
+ 'href' => array(),
1076
+ 'title' => array(),
1077
+ 'target' => array(),
1078
+ 'rel' => array(),
1079
+ ),
1080
+ 'br' => array(),
1081
+ 'em' => array(),
1082
+ 'strong' => array(),
1083
+ 'small' => array(),
1084
+ )
1085
+ ) . '</div>';
1086
+ } else {
1087
+ echo '<div class="fts-jal-fb-description">';
1088
+ echo wp_kses(
1089
+ nl2br( $fb_description ),
1090
+ array(
1091
+ 'a' => array(
1092
+ 'href' => array(),
1093
+ 'title' => array(),
1094
+ 'target' => array(),
1095
+ 'rel' => array(),
1096
+ ),
1097
+ 'br' => array(),
1098
+ 'em' => array(),
1099
+ 'strong' => array(),
1100
+ 'small' => array(),
1101
+ )
1102
+ );
1103
+ echo '</div>';
1104
+ }
1105
+ if ( ! empty( $fb_link ) ) {
1106
+ echo '<div>By: <a href="' . esc_url( $fb_link ) . '" target="_blank" rel="noreferrer">' . esc_html( $fb_by ) . '<a/></div>';
1107
+ }
1108
+ }
1109
+ }
1110
+ break;
1111
+ default:
1112
+ include_once ABSPATH . 'wp-admin/includes/plugin.php';
1113
+ if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) || is_plugin_active( 'feed-them-social-combined-streams/feed-them-social-combined-streams.php' ) ) {
1114
+ // here we trim the words for the links description text... for the premium version. The $fb_shortcode['words'] string actually comes from the javascript.
1115
+ if ( is_array( $fb_shortcode ) && array_key_exists( 'words', $fb_shortcode ) && ! empty( $fb_shortcode['words'] ) ) {
1116
+
1117
+ $trimmed_content = $trunacate_words->fts_custom_trim_words( $fb_description, $fb_shortcode['words'], $more );
1118
+ echo '<div class="jal-fb-description">' . wp_kses(
1119
+ nl2br( $trimmed_content ),
1120
+ array(
1121
+ 'a' => array(
1122
+ 'href' => array(),
1123
+ 'title' => array(),
1124
+ 'target' => array(),
1125
+ 'rel' => array(),
1126
+ ),
1127
+ 'br' => array(),
1128
+ 'em' => array(),
1129
+ 'strong' => array(),
1130
+ 'small' => array(),
1131
+ )
1132
+ ) . '</div>';
1133
+ } elseif ( is_array( $fb_shortcode ) && array_key_exists( 'words', $fb_shortcode ) && '0' !== $fb_shortcode['words'] ) {
1134
+ echo '<div class="jal-fb-description">' . wp_kses(
1135
+ nl2br( $fb_description ),
1136
+ array(
1137
+ 'a' => array(
1138
+ 'href' => array(),
1139
+ 'title' => array(),
1140
+ 'target' => array(),
1141
+ 'rel' => array(),
1142
+ ),
1143
+ 'br' => array(),
1144
+ 'em' => array(),
1145
+ 'strong' => array(),
1146
+ 'small' => array(),
1147
+ )
1148
+ ) . '</div>';
1149
+ }
1150
+ } else {
1151
+ // if the premium plugin is not active we will just show the regular full description.
1152
+ echo '<div class="jal-fb-description">' . wp_kses(
1153
+ nl2br( $fb_description ),
1154
+ array(
1155
+ 'a' => array(
1156
+ 'href' => array(),
1157
+ 'title' => array(),
1158
+ 'target' => array(),
1159
+ 'rel' => array(),
1160
+ ),
1161
+ 'br' => array(),
1162
+ 'em' => array(),
1163
+ 'strong' => array(),
1164
+ 'small' => array(),
1165
+ )
1166
+ ) . '</div>';
1167
+ }
1168
+ }
1169
+ }
1170
+
1171
+ /**
1172
+ * FTS Facebook Post Caption
1173
+ *
1174
+ * @param string $fb_caption The post caption.
1175
+ * @param string $fb_shortcode The shortcode.
1176
+ * @param string $fb_type The type of feed.
1177
+ * @param null $fb_post_id The post ID.
1178
+ * @since 1.9.6
1179
+ */
1180
+ public function fts_facebook_post_cap( $fb_caption, $fb_shortcode, $fb_type, $fb_post_id = null ) {
1181
+ $trunacate_words = new \FeedThemSocialTruncateHTML();
1182
+
1183
+ switch ( $fb_type ) {
1184
+ case 'video_direct_response' :
1185
+ case 'video_inline' :
1186
+ $fb_caption = $this->fts_facebook_tag_filter( str_replace( 'www.', '', $fb_caption ) );
1187
+ echo '<div class="fts-jal-fb-caption fb-id' . esc_attr( $fb_post_id ) . '">' . wp_kses(
1188
+ $fb_caption,
1189
+ array(
1190
+ 'a' => array(
1191
+ 'href' => array(),
1192
+ 'title' => array(),
1193
+ ),
1194
+ 'br' => array(),
1195
+ 'em' => array(),
1196
+ 'strong' => array(),
1197
+ 'small' => array(),
1198
+ )
1199
+ ) . '</div>';
1200
+ break;
1201
+ default:
1202
+ include_once ABSPATH . 'wp-admin/includes/plugin.php';
1203
+ if ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) || is_plugin_active( 'feed-them-social-combined-streams/feed-them-social-combined-streams.php' ) ) {
1204
+ // here we trim the words for the links description text... for the premium version. The $fb_shortcode['words'] string actually comes from the javascript.
1205
+ if ( array_key_exists( 'words', $fb_shortcode ) ) {
1206
+ $more = isset( $more ) ? $more : '';
1207
+ $trimmed_content = $trunacate_words->fts_custom_trim_words( $fb_caption, $fb_shortcode['words'], $more );
1208
+ echo '<div class="jal-fb-caption">' . wp_kses(
1209
+ $trimmed_content,
1210
+ array(
1211
+ 'a' => array(
1212
+ 'href' => array(),
1213
+ 'title' => array(),
1214
+ ),
1215
+ 'br' => array(),
1216
+ 'em' => array(),
1217
+ 'strong' => array(),
1218
+ 'small' => array(),
1219
+ )
1220
+ ) . '</div>';
1221
+ } else {
1222
+ $fb_caption = $this->fts_facebook_tag_filter( $fb_caption );
1223
+ echo '<div class="jal-fb-caption">' . wp_kses(
1224
+ nl2br( $fb_caption ),
1225
+ array(
1226
+ 'a' => array(
1227
+ 'href' => array(),
1228
+ 'title' => array(),
1229
+ ),
1230
+ 'br' => array(),
1231
+ 'em' => array(),
1232
+ 'strong' => array(),
1233
+ 'small' => array(),
1234
+ )
1235
+ ) . '</div>';
1236
+ }
1237
+ } else {
1238
+ // if the premium plugin is not active we will just show the regular full description.
1239
+ $fb_caption = $this->fts_facebook_tag_filter( $fb_caption );
1240
+ echo '<div class="jal-fb-caption">' . wp_kses(
1241
+ nl2br( $fb_caption ),
1242
+ array(
1243
+ 'a' => array(
1244
+ 'href' => array(),
1245
+ 'title' => array(),
1246
+ ),
1247
+ 'br' => array(),
1248
+ 'em' => array(),
1249
+ 'strong' => array(),
1250
+ 'small' => array(),
1251
+ )
1252
+ ) . '</div>';
1253
+ }
1254
+ }
1255
+ }
1256
+
1257
+ /**
1258
+ * Get Likes Shares Comments
1259
+ *
1260
+ * Get the total count for all.
1261
+ *
1262
+ * @param string $response_post_array The array from facebook.
1263
+ * @param string $post_data_key The post data Key.
1264
+ * @param string $fb_post_share_count The post Share Count.
1265
+ * @return array
1266
+ * @since 1.9.6
1267
+ */
1268
+ public function get_likes_shares_comments( $response_post_array, $post_data_key, $fb_post_share_count ) {
1269
+ $lsc_array = array();
1270
+ // Get Likes & Comments.
1271
+ if ( $response_post_array ) {
1272
+ if ( isset( $response_post_array[ $post_data_key . '_likes' ] ) ) {
1273
+ $like_count_data = json_decode( $response_post_array[ $post_data_key . '_likes' ] );
1274
+
1275
+ // Like Count.
1276
+ if ( ! empty( $like_count_data->summary->total_count ) ) {
1277
+ $fb_post_like_count = $like_count_data->summary->total_count;
1278
+ } else {
1279
+ $fb_post_like_count = 0;
1280
+ }
1281
+ if ( 0 === $fb_post_like_count ) {
1282
+ $lsc_array['likes'] = '';
1283
+ }
1284
+ if ( 1 === $fb_post_like_count ) {
1285
+ $lsc_array['likes'] = "<i class='icon-thumbs-up'></i> 1";
1286
+ }
1287
+ if ( $fb_post_like_count > '1' ) {
1288
+ $lsc_array['likes'] = "<i class='icon-thumbs-up'></i> " . esc_html( $fb_post_like_count );
1289
+ }
1290
+ }
1291
+ if ( isset( $response_post_array[ $post_data_key . '_comments' ] ) ) {
1292
+ $comment_count_data = json_decode( $response_post_array[ $post_data_key . '_comments' ] );
1293
+
1294
+ if ( ! empty( $comment_count_data->summary->total_count ) ) {
1295
+ $fb_post_comments_count = $comment_count_data->summary->total_count;
1296
+ } else {
1297
+ $fb_post_comments_count = 0;
1298
+ }
1299
+ if ( 0 === $fb_post_comments_count ) {
1300
+ $lsc_array['comments'] = '';
1301
+ }
1302
+ if ( 1 === $fb_post_comments_count ) {
1303
+ $lsc_array['comments'] = "<i class='icon-comments'></i> 1";
1304
+ $lsc_array['comments_thread'] = $comment_count_data;
1305
+
1306
+ }
1307
+ if ( $fb_post_comments_count > '1' ) {
1308
+ $lsc_array['comments'] = "<i class='icon-comments'></i> " . $fb_post_comments_count;
1309
+ $lsc_array['comments_thread'] = $comment_count_data;
1310
+ }
1311
+ }
1312
+ }
1313
+ // Shares Count.
1314
+ if ( 0 === $fb_post_share_count || ! $fb_post_share_count ) {
1315
+ $lsc_array['shares'] = '';
1316
+ }
1317
+ if ( 1 === $fb_post_share_count ) {
1318
+ $lsc_array['shares'] = "<i class='icon-file'></i> 1";
1319
+ }
1320
+ if ( $fb_post_share_count > '1' ) {
1321
+ $lsc_array['shares'] = "<i class='icon-file'></i> " . $fb_post_share_count;
1322
+ }
1323
+ return $lsc_array;
1324
+ }
1325
+
1326
+
1327
+ /**
1328
+ * FTS Facebook Post See More
1329
+ *
1330
+ * Generate See More Button.
1331
+ *
1332
+ * @param string $fb_link The facebook link.
1333
+ * @param string $lcs_array The lcs array.
1334
+ * @param string $fb_type The type of feed.
1335
+ * @param null $fb_post_id The post id.
1336
+ * @param string $fb_shortcode The shortcode.
1337
+ * @param null $fb_post_user_id The user id.
1338
+ * @param null $fb_post_single_id The single post id.
1339
+ * @param null $single_event_id The event id.
1340
+ * @param string $post_data The post data.
1341
+ * @since 1.9.6
1342
+ */
1343
+ public function fts_facebook_post_see_more( $fb_link, $lcs_array, $fb_type, $fb_post_id = null, $fb_shortcode, $fb_post_user_id = null, $fb_post_single_id = null, $single_event_id = null, $post_data ) {
1344
+
1345
+ $description = isset( $post_data->message ) ? $post_data->message : '';
1346
+ // SHOW THE FB FEED PRINT_R
1347
+ // echo'<pre>';.
1348
+ // print_r();.
1349
+ // echo'</pre>';.
1350
+ $view_on_facebook = get_option( 'fb_view_on_fb_fts' ) ? get_option( 'fb_view_on_fb_fts' ) : __( 'View on Facebook', 'feed-them-social' );
1351
+ $share_this = new feed_them_social_functions();
1352
+ switch ( $fb_type ) {
1353
+ case 'events':
1354
+ $single_event_id = 'https://www.facebook.com/events/' . $single_event_id;
1355
+ echo '<div class="fts-likes-shares-etc-wrap">';
1356
+ echo $share_this->fts_share_option( $single_event_id, $description );
1357
+ echo '<a href="' . esc_attr( $single_event_id ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-see-more">' . esc_html( $view_on_facebook ) . '</a></div>';
1358
+ break;
1359
+ case 'photo':
1360
+ if ( ! empty( $fb_link ) ) {
1361
+ echo '<div class="fts-likes-shares-etc-wrap">';
1362
+ echo $share_this->fts_share_option( $fb_link, $description );
1363
+ echo '<a href="' . esc_url( $fb_link ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-see-more">';
1364
+ } else {
1365
+ // exception for videos.
1366
+ $single_video_id = 'https://www.facebook.com/' . $fb_post_id;
1367
+ echo '<div class="fts-likes-shares-etc-wrap">';
1368
+ echo $share_this->fts_share_option( $single_video_id, $description );
1369
+ echo '<a href="' . esc_url( $single_video_id ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-see-more">';
1370
+ }
1371
+ if ( 'album_photos' === $fb_shortcode['type'] && 'yes' === $fb_shortcode['hide_date_likes_comments'] ) {
1372
+
1373
+ echo '<div class="hide-date-likes-comments-etc">' . wp_kses(
1374
+ $lcs_array['likes'] . ' ' . $lcs_array['comments'] . ' ' . $lcs_array['shares'],
1375
+ array(
1376
+ 'a' => array(
1377
+ 'href' => array(),
1378
+ 'title' => array(),
1379
+ ),
1380
+ 'i' => array(
1381
+ 'class' => array(),
1382
+ ),
1383
+ )
1384
+ ) . ' &nbsp;&nbsp;</div>';
1385
+ } else {
1386
+
1387
+ echo '' . wp_kses(
1388
+ $lcs_array['likes'] . ' ' . $lcs_array['comments'] . ' ' . $lcs_array['shares'],
1389
+ array(
1390
+ 'a' => array(
1391
+ 'href' => array(),
1392
+ 'title' => array(),
1393
+ ),
1394
+ 'i' => array(
1395
+ 'class' => array(),
1396
+ ),
1397
+ )
1398
+ ) . ' &nbsp;&nbsp;';
1399
+ }
1400
+ echo '&nbsp;' . esc_html( $view_on_facebook ) . '</a></div>';
1401
+ break;
1402
+ case 'app':
1403
+ case 'cover':
1404
+ case 'profile':
1405
+ case 'mobile':
1406
+ case 'wall':
1407
+ case 'normal':
1408
+ case 'albums':
1409
+ $url_parsed = parse_url( $fb_link, PHP_URL_QUERY );
1410
+ $params = parse_str( $url_parsed, $params );
1411
+ $new_album_url = str_replace( 'album.php?fbid=' . $params['fbid'] . '&id=' . $params['id'] . '&aid=' . $params['aid'], 'media/set/?set=a.' . $params['fbid'] . '.' . $params['aid'] . '.' . $params['id'], $fb_link );
1412
+
1413
+ echo '<div class="fts-likes-shares-etc-wrap">';
1414
+ echo $share_this->fts_share_option( $new_album_url, $description );
1415
+ echo '<a href="' . esc_url( $new_album_url ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-see-more">';
1416
+ if ( 'albums' === $fb_shortcode['type'] && 'yes' === $fb_shortcode['hide_date_likes_comments'] ) {
1417
+ } else {
1418
+
1419
+ echo '' . wp_kses(
1420
+ $lcs_array['likes'] . ' ' . $lcs_array['comments'],
1421
+ array(
1422
+ 'a' => array(
1423
+ 'href' => array(),
1424
+ 'title' => array(),
1425
+ ),
1426
+ 'i' => array(
1427
+ 'class' => array(),
1428
+ ),
1429
+ )
1430
+ ) . ' &nbsp;&nbsp;';
1431
+ }
1432
+ echo '&nbsp;' . esc_html( $view_on_facebook ) . '</a></div>';
1433
+ break;
1434
+ default:
1435
+ if ( 'yes' !== get_option( 'fb_reviews_remove_see_reviews_link' ) ) {
1436
+ if ( 'reviews' === $fb_shortcode['type'] && is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) ) {
1437
+ $fb_reviews_see_more_reviews_language = get_option( 'fb_reviews_see_more_reviews_language' ) ? get_option( 'fb_reviews_see_more_reviews_language' ) : 'See More Reviews';
1438
+
1439
+ $hide_see_more = isset( $fb_shortcode['hide_see_more_reviews_link'] ) ? $fb_shortcode['hide_see_more_reviews_link'] : 'yes';
1440
+ if ( 'yes' !== $hide_see_more ) {
1441
+ echo ' <a href="' . esc_url( 'https://www.facebook.com/' . $fb_shortcode['id'] . '/reviews' ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-see-more">' . esc_html( $fb_reviews_see_more_reviews_language, 'feed-them-social' ) . '</a>';
1442
+ }
1443
+ } else {
1444
+ $post_single_id = 'https://www.facebook.com/' . $fb_post_user_id . '/posts/' . $fb_post_single_id;
1445
+ echo '<div class="fts-likes-shares-etc-wrap">';
1446
+ echo $share_this->fts_share_option( $post_single_id, $description );
1447
+ echo '<a href="' . esc_url( $post_single_id ) . '" target="_blank" rel="noreferrer" class="fts-jal-fb-see-more">';
1448
+
1449
+ echo '' . wp_kses(
1450
+ $lcs_array['likes'] . ' ' . $lcs_array['comments'],
1451
+ array(
1452
+ 'a' => array(
1453
+ 'href' => array(),
1454
+ 'title' => array(),
1455
+ ),
1456
+ 'i' => array(
1457
+ 'class' => array(),
1458
+ ),
1459
+ )
1460
+ ) . ' &nbsp;&nbsp;&nbsp;' . esc_html( $view_on_facebook ) . '</a></div>';
1461
+ }
1462
+ }
1463
+ break;
1464
+ }
1465
+ }
1466
+
1467
+ /**
1468
+ * Get Access Token
1469
+ *
1470
+ * @return mixed
1471
+ * @since 1.9.6
1472
+ */
1473
+ public function get_access_token() {
1474
+ // The API Access Token.
1475
+ // $custom_access_token = get_option('fts_facebook_custom_api_token');
1476
+ // if (!empty($custom_access_token)) {
1477
+ // return $access_token;
1478
+ // } else {
1479
+ // Randomizer
1480
+ // $values = array(
1481
+ // '431287540548931|4A23YYIFqhd-gpz_E4Fy6U_Seo0',
1482
+ // '1748446362151826|epVUmLiKT8QhLN63iRvvXXHwxqk',
1483
+ // '1875381106044241|KmWz3mtzGye0M5HTdX0SK7rqpIU',
1484
+ // '754106341419549|AMruxCJ_ly8825VXeLhBKo_kOfs',
1485
+ // '438563519819257|1GJ8GLl1AQ7ZTvXV_Xpok_QpH6s',
1486
+ // '753693994788276|xm_PXoNRWW8WPQdcQArRpBgWn5Q',
1487
+ // '644818402385988|sABEvG0QiOaJRlNLC2NphfQLlfg',
1488
+ // '292500071162951|9MA-kzWVs6HTEybpdxKjgF_gqeo',
1489
+ // '263710677420086|Jpui2CFig7RbtdHaHPN_fiEa77U',
1490
+ // '1850081601881384|u2JcPCn7TH40MY5BwC-i4PMHGm8',
1491
+ // );
1492
+ // $access_token = $values[array_rand($values, 1)];.
1493
+ return get_option( 'fts_facebook_custom_api_token' );
1494
+ // }
1495
+ }
1496
+
1497
+ /**
1498
+ * Get View Link
1499
+ *
1500
+ * @param string $fb_shortcode The facebook feed shortcode.
1501
+ * @return string
1502
+ * @since 1.9.6
1503
+ */
1504
+ public function get_view_link( $fb_shortcode ) {
1505
+ switch ( $fb_shortcode['type'] ) {
1506
+ case 'group':
1507
+ $fts_view_fb_link = 'https://www.facebook.com/groups/' . $fb_shortcode['id'] . '/';
1508
+ break;
1509
+ case 'page':
1510
+ $fts_view_fb_link = 'https://www.facebook.com/' . $fb_shortcode['id'] . '/';
1511
+ break;
1512
+ case 'event':
1513
+ $fts_view_fb_link = 'https://www.facebook.com/events/' . $fb_shortcode['id'] . '/';
1514
+ break;
1515
+ case 'events':
1516
+ $fts_view_fb_link = 'https://www.facebook.com/' . $fb_shortcode['id'] . '/events/';
1517
+ break;
1518
+ case 'albums':
1519
+ $fts_view_fb_link = 'https://www.facebook.com/' . $fb_shortcode['id'] . '/photos_stream?tab=photos_albums';
1520
+ break;
1521
+ // album photos and videos album.
1522
+ case 'album_photos':
1523
+ $fts_view_fb_link = isset( $fb_shortcode['video_album'] ) && 'yes' === $fb_shortcode['video_album'] ? 'https://www.facebook.com/' . $fb_shortcode['id'] . '/videos/' : 'https://www.facebook.com/' . $fb_shortcode['id'] . '/photos_stream/';
1524
+ break;
1525
+ case 'hashtag':
1526
+ $fts_view_fb_link = 'https://www.facebook.com/hashtag/' . $fb_shortcode['id'] . '/';
1527
+ break;
1528
+ case 'reviews':
1529
+ $fts_view_fb_link = 'https://www.facebook.com/' . $fb_shortcode['id'] . '/reviews/';
1530
+ break;
1531
+ }
1532
+ $fts_view_fb_link = isset( $fts_view_fb_link ) ? $fts_view_fb_link : '';
1533
+ return $fts_view_fb_link;
1534
+ }
1535
+
1536
+ /**
1537
+ * Get FB Cache Name
1538
+ *
1539
+ * @param string $fb_shortcode The facebook feed shortcode.
1540
+ * @return string
1541
+ * @since 1.9.6
1542
+ */
1543
+ public function get_fb_cache_name( $fb_shortcode ) {
1544
+ // URL to get page info.
1545
+ $r_count = substr_count( $fb_shortcode['id'], ',' );
1546
+
1547
+ if ( $r_count >= 1 ) {
1548
+ $result = preg_replace( '/[ ,]+/', '-', trim( $fb_shortcode['id'] ) );
1549
+ $fb_shortcode['id'] = $result;
1550
+ }
1551
+
1552
+ switch ( $fb_shortcode['type'] ) {
1553
+ case 'album_photos':
1554
+ $fb_data_cache_name = 'fb_' . $fb_shortcode['type'] . '_' . $fb_shortcode['id'] . '_' . $fb_shortcode['album_id'] . '_num' . $fb_shortcode['posts'] . '';
1555
+ break;
1556
+ default:
1557
+ $fb_data_cache_name = 'fb_' . $fb_shortcode['type'] . '_' . $fb_shortcode['id'] . '_num' . $fb_shortcode['posts'] . '';
1558
+ break;
1559
+ }
1560
+ return $fb_data_cache_name;
1561
+ }
1562
+
1563
+ /**
1564
+ * Get Language
1565
+ *
1566
+ * @return string
1567
+ * @since 1.9.6
1568
+ */
1569
+ public function get_language() {
1570
+ // this check is in place because we used this option and it failed for many people because we use wp get contents instead of curl.
1571
+ // this can be removed in a future update and just keep the $language_option = get_option('fb_language', 'en_US');.
1572
+ $language_option_check = get_option( 'fb_language' );
1573
+ if ( isset( $language_option_check ) && 'Please Select Option' !== $language_option_check ) {
1574
+ $language_option = get_option( 'fb_language', 'en_US' );
1575
+ } else {
1576
+ $language_option = 'en_US';
1577
+ }
1578
+ return ! empty( $language_option ) ? '&locale=' . $language_option : '';
1579
+ }
1580
+
1581
+ /**
1582
+ * Get Facebook Overall Rating Response
1583
+ *
1584
+ * @param string $fb_shortcode The facebook feed shortcode.
1585
+ * @param string $fb_cache_name The Cache Name.
1586
+ * @param string $access_token The Access Token.
1587
+ * @since 2.1.3
1588
+ */
1589
+ public function get_facebook_overall_rating_response( $fb_shortcode, $fb_cache_name, $access_token ) {
1590
+
1591
+ // $mulit_data_rating = $this->fts_get_feed_json($mulit_data_rating);.
1592
+ // Error Check
1593
+ // $feed_data_rating_overall = json_decode($mulit_data['rating_data']);.
1594
+ $fb_reviews_overall_rating_of_5_stars_text = get_option( 'fb_reviews_overall_rating_of_5_stars_text' );
1595
+ $fb_reviews_overall_rating_of_5_stars_text = ! empty( $fb_reviews_overall_rating_of_5_stars_text ) ? ' ' . $fb_reviews_overall_rating_of_5_stars_text : ' of 5 stars';
1596
+ $fb_reviews_overall_rating_reviews_text = get_option( 'fb_reviews_overall_rating_reviews_text' );
1597
+ $fb_reviews_overall_rating_reviews_text = ! empty( $fb_reviews_overall_rating_reviews_text ) ? ' ' . $fb_reviews_overall_rating_reviews_text : ' reviews';
1598
+ $fb_reviews_overall_rating_background_border_hide = get_option( 'fb_reviews_overall_rating_background_border_hide' );
1599
+ $fb_reviews_overall_rating_background_border_hide = ! empty( $fb_reviews_overall_rating_background_border_hide ) && 'yes' === $fb_reviews_overall_rating_background_border_hide ? ' fts-review-details-master-wrap-no-background-or-border' : '';
1600
+
1601
+ echo '<div class="fts-review-details-master-wrap' . esc_attr( $fb_reviews_overall_rating_background_border_hide ) . '"><i class="fts-review-star">' . esc_html( $feed_data_rating_overall->overall_star_rating ) . ' &#9733;</i>';
1602
+ echo '<div class="fts-review-details-wrap" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"><div class="fts-review-details"><span itemprop="ratingValue">' . esc_html( $feed_data_rating_overall->overall_star_rating ) . '</span>' . esc_html( $fb_reviews_overall_rating_of_5_stars_text ) . '</div>';
1603
+ echo '<div class="fts-review-details-count"><span itemprop="reviewCount">' . esc_html( $feed_data_rating_overall->rating_count ) . '</span>' . esc_html( $fb_reviews_overall_rating_reviews_text ) . '</div></div></div>';
1604
+
1605
+ // $fb_cache_name = $fb_shortcode['id'] . $this->rand_string(10);
1606
+ // Make sure it's not ajaxing
1607
+ // if (!isset($_GET['load_more_ajaxing'])) {
1608
+ // Create Cache
1609
+ // $FTS_FB_OUTPUT = $this->fts_create_feed_cache($fb_cache_name, $feed_data_rating_overall);
1610
+ // }.
1611
+ }
1612
+
1613
+
1614
+ /**
1615
+ * Get Facebook Feed Response
1616
+ *
1617
+ * @param string $fb_shortcode The facebook shortcode.
1618
+ * @param string $fb_cache_name FB cache name.
1619
+ * @param string $access_token The Access Token.
1620
+ * @param string $language Language.
1621
+ * @return array|mixed
1622
+ * @throws \Exception
1623
+ * @since 1.9.6
1624
+ */
1625
+ public function get_facebook_feed_response( $fb_shortcode, $fb_cache_name, $access_token, $language ) {
1626
+
1627
+ if ( is_plugin_active( 'feed-them-social-combined-streams/feed-them-social-combined-streams.php' ) ) {
1628
+ $fts_count_ids = substr_count( $fb_shortcode['id'], ',' );
1629
+ } else {
1630
+ $fts_count_ids = '';
1631
+ }
1632
+
1633
+ if ( false !== $this->fts_check_feed_cache_exists( $fb_cache_name ) && ! isset( $_GET['load_more_ajaxing'] ) ) {
1634
+ $response = $this->fts_get_feed_cache( $fb_cache_name );
1635
+ } else {
1636
+ // Page.
1637
+ if ( 'page' === $fb_shortcode['type'] && 'page_only' === $fb_shortcode['posts_displayed'] ) {
1638
+ $mulit_data = array( 'page_data' => 'https://graph.facebook.com/' . $fb_shortcode['id'] . '?fields=id,name,description&access_token=' . $access_token . $language . '' );
1639
+
1640
+ if ( isset( $_REQUEST['next_url'] ) ) {
1641
+ $_REQUEST['next_url'] = str_replace( 'access_token=XXX', 'access_token=' . get_option( 'fts_facebook_custom_api_token' ), $_REQUEST['next_url'] );
1642
+ }
1643
+
1644
+ if ( ! $fts_count_ids >= 1 ) {
1645
+ // We cannot add sanitize_text_field here on the $_REQUEST['next_url'] otherwise it will fail to load the contents from the facebook API.
1646
+ $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/' . $fb_shortcode['id'] . '/posts?fields=id,attachments,created_time,from,icon,message,picture,full_picture,place,shares,status_type,story,to&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1647
+ } else {
1648
+ $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/posts?ids=' . $fb_shortcode['id'] . '&fields=id,attachments,created_time,from,icon,message,picture,full_picture,place,shares,status_type,story,to&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1649
+ }
1650
+ } elseif (
1651
+ // Albums.
1652
+ 'albums' === $fb_shortcode['type'] ) {
1653
+ $mulit_data = array( 'page_data' => 'https://graph.facebook.com/' . $fb_shortcode['id'] . '?fields=id,name,description,link&access_token=' . $access_token . $language . '' );
1654
+ if ( isset( $_REQUEST['next_url'] ) ) {
1655
+ $_REQUEST['next_url'] = str_replace( 'access_token=XXX', 'access_token=' . get_option( 'fts_facebook_custom_api_token' ), $_REQUEST['next_url'] );
1656
+ }
1657
+ // Check If Ajax next URL needs to be used.
1658
+ if ( ! $fts_count_ids >= 1 ) {
1659
+ $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : wp_unslash( 'https://graph.facebook.com/' . $fb_shortcode['id'] . '/albums?fields=id,photos{images,name,created_time},created_time,name,from,link,cover_photo,count,updated_time,type&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1660
+ } else {
1661
+ $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : wp_unslash( 'https://graph.facebook.com/albums?ids=' . $fb_shortcode['id'] . '&fields=id,photos{images,name,created_time},created_time,name,from,link,cover_photo,count,updated_time,type&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1662
+ }
1663
+
1664
+ // $mulit_data['feed_data'] = isset($_REQUEST['next_url']) ? esc_url_raw($_REQUEST['next_url']) : 'https://graph.facebook.com/' . $fb_shortcode['id'] . '/albums?fields=id,created_time,name,from,cover_photo,count,updated_time&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '';
1665
+ } elseif (
1666
+ // Album Photos.
1667
+ 'album_photos' === $fb_shortcode['type'] ) {
1668
+ $mulit_data = array( 'page_data' => 'https://graph.facebook.com/' . $fb_shortcode['id'] . '?fields=id,name,description&access_token=' . $access_token . $language . '' );
1669
+ if ( isset( $_REQUEST['next_url'] ) ) {
1670
+ $_REQUEST['next_url'] = str_replace( 'access_token=XXX', 'access_token=' . get_option( 'fts_facebook_custom_api_token' ), $_REQUEST['next_url'] );
1671
+ }
1672
+ // Check If Ajax next URL needs to be used
1673
+ // The reason I did not create a whole new else if for the video album is because I did not want to duplicate all the code required to make the video because the videos gallery comes from the photo albums on facebook.
1674
+ if ( isset( $fb_shortcode['video_album'] ) && 'yes' === $fb_shortcode['video_album'] ) {
1675
+ if ( ! $fts_count_ids >= 1 ) {
1676
+ $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/' . $fb_shortcode['id'] . '/videos?fields=id,created_time,description,from,icon,link,message,object_id,picture,place,source,to,type,format,embed_html&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1677
+ } else {
1678
+ $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/videos?ids=' . $fb_shortcode['id'] . '&fields=id,created_time,description,from,icon,link,message,object_id,picture,place,source,to,type,format,embed_html&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1679
+ }
1680
+ } elseif ( isset( $fb_shortcode['album_id'] ) && 'photo_stream' === $fb_shortcode['album_id'] ) {
1681
+ if ( ! $fts_count_ids >= 1 ) {
1682
+ $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/' . $fb_shortcode['id'] . '/photos?fields=id,caption,created_time,description,from,icon,link,message,name,object_id,picture,place,shares,source,status_type,story,to,type&type=uploaded&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1683
+ } else {
1684
+ $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/photos?ids=' . $fb_shortcode['id'] . '&fields=id,caption,created_time,description,from,icon,link,message,name,object_id,picture,place,shares,source,status_type,story,to,type&type=uploaded&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1685
+ }
1686
+ } else {
1687
+ if ( ! $fts_count_ids >= 1 ) {
1688
+ $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/' . $fb_shortcode['album_id'] . '/photos?fields=id,caption,created_time,description,from,icon,link,message,name,object_id,picture,place,shares,source,status_type,story,to,type&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1689
+ } else {
1690
+ $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/photos?ids=' . $fb_shortcode['album_id'] . '&fields=id,caption,created_time,description,from,icon,link,message,name,object_id,picture,place,shares,source,status_type,story,to,type&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1691
+ }
1692
+ }
1693
+ } elseif ( 'reviews' === $fb_shortcode['type'] ) {
1694
+
1695
+ // Reviews.
1696
+ if ( is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) ) {
1697
+ $fts_facebook_reviews = new FTS_Facebook_Reviews();
1698
+ $mulit_data = $fts_facebook_reviews->review_connection( $fb_shortcode, $access_token, $language );
1699
+
1700
+ $mulit_data['ratings_data'] = esc_url_raw( 'https://graph.facebook.com/' . $fb_shortcode['id'] . '/?fields=overall_star_rating,rating_count&access_token=' . $access_token . '' );
1701
+
1702
+ } else {
1703
+ return 'Please Purchase and Activate the Feed Them Social Reviews plugin.';
1704
+ exit;
1705
+ }
1706
+ } else {
1707
+ $mulit_data = array( 'page_data' => 'https://graph.facebook.com/' . $fb_shortcode['id'] . '?fields=feed,id,name,description&access_token=' . $access_token . $language . '' );
1708
+
1709
+ // Check If Ajax next URL needs to be used.
1710
+ if ( ! $fts_count_ids >= 1 ) {
1711
+ $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/' . $fb_shortcode['id'] . '/feed?fields=id,created_time,from,icon,message,name_id,picture,full_picture,place,shares,status_type,story,to&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1712
+ } else {
1713
+ $mulit_data['feed_data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : esc_url_raw( 'https://graph.facebook.com/feed?ids=' . $fb_shortcode['id'] . '&fields=id,created_time,from,icon,message,name_id,picture,full_picture,place,shares,status_type,story,to&limit=' . $fb_shortcode['posts'] . '&access_token=' . $access_token . $language . '' );
1714
+ }
1715
+ }
1716
+ $response = $this->fts_get_feed_json( $mulit_data );
1717
+
1718
+ if ( ! isset( $_GET['load_more_ajaxing'] ) ) {
1719
+ // Error Check.
1720
+ $feed_data = json_decode( $response['feed_data'] );
1721
+ $fts_error_check = new fts_error_handler();
1722
+ $fts_error_check_complete = $fts_error_check->facebook_error_check( $fb_shortcode, $feed_data );
1723
+ if ( is_array( $fts_error_check_complete ) && true === $fts_error_check_complete[0] ) {
1724
+
1725
+ // If old Cache exists use it instead of showing an error.
1726
+ if ( true === $this->fts_check_feed_cache_exists( $fb_cache_name, true ) ) {
1727
+
1728
+ // If Current user is Admin and Cache exists for use then still show Admin the error for debugging purposes.
1729
+ if ( current_user_can( 'administrator' ) ) {
1730
+ echo wp_kses(
1731
+ $fts_error_check_complete[1] . ' <em>**NOTE** This error is only shown to logged in Admins of this WordPress install</em>',
1732
+ array(
1733
+ 'a' => array(
1734
+ 'href' => array(),
1735
+ 'title' => array(),
1736
+ ),
1737
+ 'br' => array(),
1738
+ 'em' => array(),
1739
+ 'strong' => array(),
1740
+ )
1741
+ );
1742
+ }
1743
+
1744
+ // Return Cache because it exists in Database. Better than showing nothing right?
1745
+ return $this->fts_get_feed_cache( $fb_cache_name, true );
1746
+ }
1747
+ // If User is Admin and no Old cache is saved in database for use.
1748
+ if ( current_user_can( 'administrator' ) ) {
1749
+ return array( false, $fts_error_check_complete[1] );
1750
+ }
1751
+ }
1752
+ }
1753
+
1754
+ // Make sure it's not ajaxing.
1755
+ if ( ! empty( $response['feed_data'] ) ) {
1756
+ // Create Cache.
1757
+ $this->fts_create_feed_cache( $fb_cache_name, $response );
1758
+ }
1759
+ } // end main else.
1760
+
1761
+ return $response;
1762
+
1763
+ }
1764
+
1765
+
1766
+ /**
1767
+ * Get Facebook Feed Dynamic Name
1768
+ *
1769
+ * @param string $fb_shortcode The facebook feed shortcode.
1770
+ * @return mixed
1771
+ * @since 1.9.6
1772
+ */
1773
+ public function get_facebook_feed_dynamic_name( $fb_shortcode ) {
1774
+
1775
+ return $_REQUEST['fts_dynamic_name'] = sanitize_key( $this->fts_rand_string( 10 ) . '_' . $fb_shortcode['type'] );
1776
+
1777
+ }
1778
+
1779
+ /**
1780
+ * Get Facebook Feed Dynamic Class Name
1781
+ *
1782
+ * @param null $fts_dynamic_name Our Dynamic Name for ajax.
1783
+ * @return string
1784
+ * @since 1.9.6
1785
+ */
1786
+ public function get_facebook_feed_dynamic_class_name( $fts_dynamic_name = null ) {
1787
+ $fts_dynamic_class_name = '';
1788
+ if ( isset( $fts_dynamic_name ) ) {
1789
+ $fts_dynamic_class_name = 'feed_dynamic_class' . sanitize_key( $_REQUEST['fts_dynamic_name'] );
1790
+ }
1791
+ return $fts_dynamic_class_name;
1792
+ }
1793
+
1794
+
1795
+ /**
1796
+ * Get Post Info
1797
+ *
1798
+ * For Facebook.
1799
+ *
1800
+ * @param string $feed_data The facebook contents.
1801
+ * @param string $fb_shortcode FB cache name.
1802
+ * @param string $access_token The Access Token.
1803
+ * @param string $language Language.
1804
+ * @return array|mixed
1805
+ * @since 1.9.6
1806
+ */
1807
+ public function get_post_info( $feed_data, $fb_shortcode, $access_token, $language, $fb_cache_name ) {
1808
+ $developer_mode = get_option( 'fts_clear_cache_developer_mode' );
1809
+
1810
+ if ( 'album_photos' === $fb_shortcode['type'] ) {
1811
+ $fb_post_data_cache = 'fb_' . $fb_shortcode['type'] . '_post_' . $fb_shortcode['album_id'] . '_num' . $fb_shortcode['posts'] . '';
1812
+ } else {
1813
+ $fb_post_data_cache = 'fb_' . $fb_shortcode['type'] . '_post_' . $fb_shortcode['id'] . '_num' . $fb_shortcode['posts'] . '';
1814
+ }
1815
+ if ( false !== $this->fts_check_feed_cache_exists( $fb_post_data_cache ) && ! isset( $_GET['load_more_ajaxing'] ) ) {
1816
+ $response_post_array = $this->fts_get_feed_cache( $fb_post_data_cache );
1817
+
1818
+ } else {
1819
+ // Build the big post counter.
1820
+ $fb_post_array = array();
1821
+ // Single Events Array.
1822
+ $set_zero = 0;
1823
+ foreach ( $feed_data->data as $counter ) {
1824
+
1825
+ $counter->id = isset( $counter->id ) ? $counter->id : '';
1826
+
1827
+ if ( $set_zero === $fb_shortcode['posts'] ) {
1828
+ break;
1829
+ }
1830
+
1831
+ $fb_type = isset( $counter->attachments->data[0]->type ) ? $counter->attachments->data[0]->type : '';
1832
+ $post_data_key = isset( $counter->attachments->data[0]->object_id) ? $counter->attachments->data[0]->object_id: $counter->id;
1833
+
1834
+ // Likes & Comments.
1835
+ $fb_post_array[ $post_data_key . '_likes' ] = 'https://graph.facebook.com/' . $post_data_key . '/reactions?summary=1&access_token=' . $access_token;
1836
+ $fb_post_array[ $post_data_key . '_comments' ] = 'https://graph.facebook.com/' . $post_data_key . '/comments?summary=1&access_token=' . $access_token;
1837
+ // Video.
1838
+ if ( 'video' === $fb_type ) {
1839
+ $fb_post_array[ $post_data_key . '_video' ] = 'https://graph.facebook.com/' . $post_data_key;
1840
+ }
1841
+ // Photo.
1842
+ $fb_album_cover = isset( $counter->cover_photo->id ) ? $counter->cover_photo->id : '';
1843
+ if ( 'albums' === $fb_shortcode['type'] && ! $fb_album_cover ) {
1844
+ unset( $counter );
1845
+ continue;
1846
+ }
1847
+ if ( 'albums' === $fb_shortcode['type'] ) {
1848
+ $fb_post_array[ $fb_album_cover . '_photo' ] = 'https://graph.facebook.com/' . $fb_album_cover;
1849
+ }
1850
+ if ( 'hashtag' === $fb_shortcode['type'] ) {
1851
+ $fb_post_array[ $post_data_key . '_photo' ] = 'https://graph.facebook.com/' . $counter->source;
1852
+ }
1853
+ // GROUP Photo.
1854
+ if ( 'group' === $fb_shortcode['type'] ) {
1855
+ $fb_post_array[ $post_data_key . '_group_post_photo' ] = 'https://graph.facebook.com/' . $counter->id . '?fields=picture,full_picture&access_token=' . $access_token;
1856
+ }
1857
+
1858
+ $set_zero++;
1859
+ }
1860
+
1861
+ $fts_error_check = new fts_error_handler();
1862
+ $fts_error_check_complete = $fts_error_check->facebook_error_check( $fb_shortcode, $feed_data );
1863
+ if ( is_array( $fts_error_check_complete ) && true === $fts_error_check_complete[0] ) {
1864
+
1865
+ // If old Cache exists use it instead of showing an error.
1866
+ if ( true === $this->fts_check_feed_cache_exists( $fb_cache_name, true ) ) {
1867
+
1868
+ // Return Cache because it exists in Database. Better than showing nothing right?
1869
+ return $this->fts_get_feed_cache( $fb_cache_name, true );
1870
+ }
1871
+ }
1872
+
1873
+ // Response.
1874
+ $response_post_array = $this->fts_get_feed_json( $fb_post_array );
1875
+ // Make sure it's not ajaxing.
1876
+ if ( ! isset( $_GET['load_more_ajaxing'] ) ) {
1877
+ // Create Cache.
1878
+ $this->fts_create_feed_cache( $fb_post_data_cache, $response_post_array );
1879
+ }
1880
+ }
1881
+ // SHOW THE POST RESPONSE PRINT_R
1882
+ // echo'<pre>';
1883
+ // print_r($response_post_array);
1884
+ // echo'</pre>';.
1885
+ return $response_post_array;
1886
+ }
1887
+
1888
+
1889
+ /**
1890
+ * Get Post Info
1891
+ *
1892
+ * For Facebook.
1893
+ *
1894
+ * @param string $feed_data The facebook contents.
1895
+ * @param string $fb_shortcode FB cache name.
1896
+ * @param string $access_token The Access Token.
1897
+ * @param string $language Language.
1898
+ * @return array|mixed
1899
+ * @since 2.1.6
1900
+ */
1901
+ public function get_event_post_info( $feed_data, $fb_shortcode, $access_token, $language ) {
1902
+ $developer_mode = get_option( 'fts_clear_cache_developer_mode' );
1903
+
1904
+ $fb_event_post_data_cache = 'fbe_' . $fb_shortcode['type'] . '_post_' . $fb_shortcode['id'] . '_num' . $fb_shortcode['posts'] . '';
1905
+ if ( false !== $this->fts_check_feed_cache_exists( $fb_event_post_data_cache ) && ! isset( $_GET['load_more_ajaxing'] ) ) {
1906
+ $response_event_post_array = $this->fts_get_feed_cache( $fb_event_post_data_cache );
1907
+ } else {
1908
+ // Single Events Array.
1909
+ $fb_single_events_array = array();
1910
+ $set_zero = 0;
1911
+ foreach ( $feed_data->data as $counter ) {
1912
+
1913
+ $counter->id = isset( $counter->id ) ? $counter->id : '';
1914
+
1915
+ if ( $set_zero === $fb_shortcode['posts'] ) {
1916
+ break;
1917
+ }
1918
+
1919
+ $single_event_id = $counter->id;
1920
+ $language = isset( $language ) ? $language : '';
1921
+ // Event Info, Time etc.
1922
+ $fb_single_events_array[ 'event_single_' . $single_event_id . '_info' ] = 'https://graph.facebook.com/' . $single_event_id . '/?access_token=' . $access_token . $language;
1923
+ // Event Location.
1924
+ $fb_single_events_array[ 'event_single_' . $single_event_id . '_location' ] = 'https://graph.facebook.com/' . $single_event_id . '/?fields=place&access_token=' . $access_token . $language;
1925
+ // Event Cover Photo.
1926
+ $fb_single_events_array[ 'event_single_' . $single_event_id . '_cover_photo' ] = 'https://graph.facebook.com/' . $single_event_id . '/?fields=cover&access_token=' . $access_token . $language;
1927
+ // Event Ticket Info.
1928
+ $fb_single_events_array[ 'event_single_' . $single_event_id . '_ticket_info' ] = 'https://graph.facebook.com/' . $single_event_id . '/?fields=ticket_uri&access_token=' . $access_token . $language;
1929
+
1930
+ $set_zero++;
1931
+ }
1932
+
1933
+ $response_event_post_array = $this->fts_get_feed_json( $fb_single_events_array );
1934
+ // Create Cache.
1935
+ $this->fts_create_feed_cache( $fb_event_post_data_cache, $response_event_post_array );
1936
+
1937
+ }
1938
+ // SHOW THE $response_event_post_array FEED PRINT_R
1939
+ // '<pre>';.
1940
+ // print_r($response_event_post_array);
1941
+ // echo'</pre>';.
1942
+ return $response_event_post_array;
1943
+ }
1944
+
1945
+
1946
+ /**
1947
+ * FB Social Button Placement
1948
+ *
1949
+ * @param string $fb_shortcode The facebook contents.
1950
+ * @param string $access_token The Access Token.
1951
+ * @param string $share_loc Language.
1952
+ * @return string|void
1953
+ * @since 2.0.1
1954
+ */
1955
+ public function fb_social_btn_placement( $fb_shortcode, $access_token, $share_loc ) {
1956
+ // Don't do it for these!
1957
+ if ( 'group' === $fb_shortcode['type'] || 'event' === $fb_shortcode['type'] || isset( $fb_shortcode['hide_like_option'] ) && 'yes' === $fb_shortcode['hide_like_option'] ) {
1958
+ return;
1959
+ }
1960
+ // Facebook Follow Button Options.
1961
+ $fb_show_follow_btn = get_option( 'fb_show_follow_btn' );
1962
+
1963
+ if ( isset( $fb_shortcode['show_follow_btn_where'] ) && '' !== $fb_shortcode['show_follow_btn_where'] ) {
1964
+ if ( 'above_title' === $fb_shortcode['show_follow_btn_where'] ) {
1965
+ $fb_show_follow_btn_where = 'fb-like-top-above-title';
1966
+ } elseif ( 'below_title' === $fb_shortcode['show_follow_btn_where'] ) {
1967
+ $fb_show_follow_btn_where = 'fb-like-top-below-title';
1968
+ } elseif ( 'bottom' === $fb_shortcode['show_follow_btn_where'] ) {
1969
+ $fb_show_follow_btn_where = 'fb-like-below';
1970
+ }
1971
+ } else {
1972
+ $fb_show_follow_btn_where = get_option( 'fb_show_follow_btn_where' );
1973
+ }
1974
+
1975
+ if ( ! isset( $_GET['load_more_ajaxing'] ) ) {
1976
+
1977
+ $like_option_align_final = isset( $fb_shortcode['like_option_align'] ) ? 'fts-fb-social-btn-' . $fb_shortcode['like_option_align'] . '' : '';
1978
+
1979
+ if ( $share_loc === $fb_show_follow_btn_where ) {
1980
+ switch ( $fb_show_follow_btn_where ) {
1981
+ case 'fb-like-top-above-title':
1982
+ // Top Above Title.
1983
+ if ( isset( $fb_show_follow_btn ) && 'dont-display' !== $fb_show_follow_btn ) {
1984
+ echo '<div class="fb-social-btn-top ' . esc_attr( $like_option_align_final ) . '">';
1985
+ $this->social_follow_button( 'facebook', $fb_shortcode['id'], $access_token, $fb_shortcode );
1986
+ echo '</div>';
1987
+ }
1988
+ break;
1989
+ // Top Below Title.
1990
+ case 'fb-like-top-below-title':
1991
+ if ( isset( $fb_show_follow_btn ) && 'dont-display' !== $fb_show_follow_btn ) {
1992
+ echo '<div class="fb-social-btn-below-description ' . esc_attr( $like_option_align_final ) . '">';
1993
+ $this->social_follow_button( 'facebook', $fb_shortcode['id'], $access_token, $fb_shortcode );
1994
+ echo '</div>';
1995
+ }
1996
+ break;
1997
+ // Bottom.
1998
+ case 'fb-like-below':
1999
+ if ( isset( $fb_show_follow_btn ) && 'dont-display' !== $fb_show_follow_btn ) {
2000
+ echo '<div class="fb-social-btn-bottom ' . esc_attr( $like_option_align_final ) . '">';
2001
+ $this->social_follow_button( 'facebook', $fb_shortcode['id'], $access_token, $fb_shortcode );
2002
+ echo '</div>';
2003
+ }
2004
+ break;
2005
+ }
2006
+ }
2007
+ }
2008
+ }
2009
+
2010
+ /**
2011
+ * FTS Custom Trim Words
2012
+ *
2013
+ * Not using this anymore but keeping it as a fallback function for the combined if user has not updated the free version before the combined extension
2014
+ *
2015
+ * @param string $text The description text.
2016
+ * @param int $num_words Number of words you want to be showm.
2017
+ * @param string $more The ...
2018
+ * @return mixed
2019
+ * @since 1.9.6
2020
+ */
2021
+ public function fts_custom_trim_words( $text, $num_words = 45, $more ) {
2022
+ ! empty( $num_words ) && 0 !== $num_words ? $more = __( '...' ) : '';
2023
+ $text = nl2br( $text );
2024
+ // Filter for Hashtags and Mentions Before returning.
2025
+ $text = $this->fts_facebook_tag_filter( $text );
2026
+ $text = strip_shortcodes( $text );
2027
+ // Add tags that you don't want stripped.
2028
+ $text = strip_tags( $text, '<strong><br><em><i><a>' );
2029
+ $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY );
2030
+ $sep = ' ';
2031
+ if ( count( $words_array ) > $num_words ) {
2032
+ array_pop( $words_array );
2033
+ $text = implode( $sep, $words_array );
2034
+ $text = $text . $more;
2035
+ } else {
2036
+ $text = implode( $sep, $words_array );
2037
+ }
2038
+ return wpautop( $text );
2039
+ }
2040
+
2041
+ /**
2042
+ * FTS Facebook Tag Filter
2043
+ *
2044
+ * Tags Filter (return clean tags)
2045
+ *
2046
+ * @param string $fb_description Facebook Description.
2047
+ * @return mixed
2048
+ * @since 1.9.6
2049
+ */
2050
+ public function fts_facebook_tag_filter( $fb_description ) {
2051
+ // Converts URLs to Links.
2052
+ $fb_description = preg_replace( '@(?!(?!.*?<a)[^<]*<\/a>)(?:(?:https?|ftp|file)://|www\.|ftp\.)[-A-‌​Z0-9+&#/%=~_|$?!:,.]*[A-Z0-9+&#/%=~_|$]@i', '<a href="\0" target="_blank" rel="noreferrer">\0</a>', $fb_description );
2053
+
2054
+ $splitano = explode( 'www', $fb_description );
2055
+ $count = count( $splitano );
2056
+ $return_value = '';
2057
+
2058
+ for ( $i = 0; $i < $count; $i++ ) {
2059
+ if ( 'href=' === substr( $splitano[ $i ], -6, 5 ) ) {
2060
+ $return_value .= $splitano[ $i ] . 'http://www';
2061
+ } elseif ( $i < $count - 1 ) {
2062
+ $return_value .= $splitano[ $i ] . 'www';
2063
+ } else {
2064
+ $return_value .= $splitano[ $i ];
2065
+ }
2066
+ }
2067
+ // Mentions.
2068
+ $return_value = preg_replace( '/@+(\w+)/u', '<a href="https://www.facebook.com/$1" target="_blank" rel="noreferrer">@$1</a>', $return_value );
2069
+ // Hash tags.
2070
+ $return_value = preg_replace( '/#+(\w+)/u', '<a href="https://www.facebook.com/hashtag/$1" target="_blank" rel="noreferrer">#$1</a>', $return_value );
2071
+
2072
+ return $return_value;
2073
+ }
2074
+
2075
+ /**
2076
+ * Load PopUp Scripts
2077
+ *
2078
+ * @param string $fb_shortcode The Facebook feed shortcode.
2079
+ * @since 1.9.6
2080
+ */
2081
+ public function load_popup_scripts( $fb_shortcode ) {
2082
+ if ( 'yes' === $fb_shortcode['popup'] ) {
2083
+ // it's ok if these styles & scripts load at the bottom of the page.
2084
+ $fts_fix_magnific = get_option( 'fts_fix_magnific' ) ? get_option( 'fts_fix_magnific' ) : '';
2085
+ if ( isset( $fts_fix_magnific ) && '1' !== $fts_fix_magnific ) {
2086
+ wp_enqueue_style( 'fts-popup', plugins_url( 'feed-them-social/feeds/css/magnific-popup.css' ), array(), FTS_CURRENT_VERSION, false );
2087
+ }
2088
+ wp_enqueue_script( 'fts-popup-js', plugins_url( 'feed-them-social/feeds/js/magnific-popup.js' ), array(), FTS_CURRENT_VERSION, false );
2089
+ wp_enqueue_script( 'fts-images-loaded', plugins_url( 'feed-them-social/feeds/js/imagesloaded.pkgd.min.js' ), array(), FTS_CURRENT_VERSION, false );
2090
+ if ( ! isset( $fb_shortcode['video_album'] ) && 'yes' === $fb_shortcode['video_album'] ) {
2091
+ wp_enqueue_script( 'fts-global', plugins_url( 'feed-them-social/feeds/js/fts-global.js' ), array( 'jquery' ), FTS_CURRENT_VERSION, false );
2092
+ }
2093
+ }
2094
+ }
2095
+
2096
+ /**
2097
+ * FTS Facebook LoadMore
2098
+ *
2099
+ * @param string $atts The shortcode attributes.
2100
+ * @param string $feed_data The Feed data.
2101
+ * @param string $fb_type The type of facebook feed.
2102
+ * @param string $fb_shortcode The Facebook feed shortcode.
2103
+ * @since 1.9.6
2104
+ */
2105
+ public function fts_facebook_loadmore( $atts, $feed_data, $fb_type, $fb_shortcode ) {
2106
+ if ( ( isset( $fb_shortcode['loadmore'] ) && 'button' === $fb_shortcode['loadmore'] || isset( $fb_shortcode['loadmore'] ) && 'autoscroll' === $fb_shortcode['loadmore'] ) && ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && 'reviews' !== $fb_shortcode['type'] || is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && 'reviews' === $fb_shortcode['type'] ) ) {
2107
+
2108
+ $fb_load_more_text = get_option( 'fb_load_more_text' ) ? get_option( 'fb_load_more_text' ) : esc_html( 'Load More', 'feed-them-social' );
2109
+ $fb_no_more_posts_text = get_option( 'fb_no_more_posts_text' ) ? get_option( 'fb_no_more_posts_text' ) : esc_html( 'No More Posts', 'feed-them-social' );
2110
+ $fb_no_more_photos_text = get_option( 'fb_no_more_photos_text' ) ? get_option( 'fb_no_more_photos_text' ) : esc_html( 'No More Photos', 'feed-them-social' );
2111
+ $fb_no_more_videos_text = get_option( 'fb_no_more_videos_text' ) ? get_option( 'fb_no_more_videos_text' ) : esc_html( 'No More Videos', 'feed-them-social' );
2112
+ $fb_no_more_reviews_text = get_option( 'fb_no_more_reviews_text' ) ? get_option( 'fb_no_more_reviews_text' ) : esc_html( 'No More Reviews', 'feed-them-social' );
2113
+
2114
+ // Load More BUTTON Start.
2115
+ $next_url = isset( $feed_data->paging->next ) ? $feed_data->paging->next : '';
2116
+
2117
+ $posts = isset( $fb_shortcode['posts'] ) ? $fb_shortcode['posts'] : '';
2118
+ $loadmore_count = isset( $fb_shortcode['loadmore_count'] ) && '' !== $fb_shortcode['loadmore_count'] ? $fb_shortcode['loadmore_count'] : '';
2119
+ // we check to see if the loadmore count number is set and if so pass that as the new count number when fetching the next set of posts.
2120
+ $_REQUEST['next_url'] = '' !== $loadmore_count ? str_replace( "limit=$posts", "limit=$loadmore_count", $next_url ) : $next_url;
2121
+
2122
+ $access_token = is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) ? 'access_token=' . get_option( 'fts_facebook_custom_api_token_biz' ) : 'access_token=' . get_option( 'fts_facebook_custom_api_token' );
2123
+ $_REQUEST['next_url'] = str_replace( $access_token, 'access_token=XXX', $next_url );
2124
+
2125
+ echo '<script>';
2126
+ echo 'var nextURL_' . esc_js( $_REQUEST['fts_dynamic_name'] ) . '= "' . esc_url_raw( $_REQUEST['next_url'] ) . '";';
2127
+ echo '</script>';
2128
+
2129
+ // Make sure it's not ajaxing.
2130
+ if ( ! isset( $_GET['load_more_ajaxing'] ) && ! isset( $_REQUEST['fts_no_more_posts'] ) && ! empty( $fb_shortcode['loadmore'] ) ) {
2131
+ $fts_dynamic_name = $_REQUEST['fts_dynamic_name'];
2132
+ $time = time();
2133
+ $nonce = wp_create_nonce( $time . 'load-more-nonce' );
2134
+ $fts_dynamic_class_name = $this->get_fts_dynamic_class_name();
2135
+ echo '<script>';
2136
+ echo 'jQuery(document).ready(function() {';
2137
+ if ( 'autoscroll' === $fb_shortcode['loadmore'] ) {
2138
+ // this is where we do SCROLL function to LOADMORE if = autoscroll in shortcode.
2139
+ echo 'jQuery(".' . esc_js( $fts_dynamic_class_name ) . '").bind("scroll",function() {';
2140
+ echo 'if(jQuery(this).scrollTop() + jQuery(this).innerHeight() >= jQuery(this)[0].scrollHeight) {';
2141
+ } else {
2142
+ // this is where we do CLICK function to LOADMORE if = button in shortcode.
2143
+ echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").click(function() {';
2144
+ }
2145
+ echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").addClass("fts-fb-spinner");';
2146
+ echo 'var button = jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").html("<div class=\'bounce1\'></div><div class=\'bounce2\'></div><div class=\'bounce3\'></div>");';
2147
+ echo 'console.log(button);';
2148
+
2149
+ echo 'var yes_ajax = "yes";';
2150
+ echo 'var fts_d_name = "' . esc_js( $fts_dynamic_name ) . '";';
2151
+ echo 'var fts_security = "' . esc_js( $nonce ) . '";';
2152
+ echo 'var fts_time = "' . esc_js( $time ) . '";';
2153
+
2154
+ echo 'var feed_name = "fts_facebook";';
2155
+ echo 'var loadmore_count = "posts=' . esc_js( $fb_shortcode['loadmore_count'] ) . '";';
2156
+ echo 'var feed_attributes = ' . json_encode( $atts ) . ';';
2157
+
2158
+ echo 'jQuery.ajax({';
2159
+ echo 'data: {action: "my_fts_fb_load_more", next_url: nextURL_' . esc_js( $fts_dynamic_name ) . ', fts_dynamic_name: fts_d_name, feed_name: feed_name, loadmore_count: loadmore_count, feed_attributes: feed_attributes, load_more_ajaxing: yes_ajax, fts_security: fts_security, fts_time: fts_time},';
2160
+ echo 'type: "GET",';
2161
+ echo 'url: "' . esc_url( admin_url( 'admin-ajax.php' ) ) . '",';
2162
+ echo 'success: function( data ) {';
2163
+ echo 'console.log("Well Done and got this from sever: " + data);';
2164
+ if ( $fb_type && 'albums' === $fb_shortcode['type'] || $fb_type && 'album_photos' === $fb_shortcode['type'] && 'yes' !== $fb_shortcode['video_album'] || 'yes' === $fb_shortcode['grid'] ) {
2165
+ echo 'jQuery(".' . esc_js( $fts_dynamic_class_name ) . '").append(data).filter(".' . esc_js( $fts_dynamic_class_name ) . '").html();';
2166
+ // if (isset($fb_shortcode['image_stack_animation']) && $fb_shortcode['image_stack_animation'] == 'yes') {.
2167
+ echo 'jQuery(".' . esc_js( $fts_dynamic_class_name ) . '").masonry( "reloadItems");';
2168
+ echo 'jQuery(".' . esc_js( $fts_dynamic_class_name ) . '").masonry("layout");';
2169
+
2170
+ echo 'setTimeout(function() {';
2171
+ // Do something after 3 seconds
2172
+ // This can be direct code, or call to some other function.
2173
+ echo 'jQuery(".' . esc_js( $fts_dynamic_class_name ) . '").masonry("layout");';
2174
+ echo '}, 500);';
2175
+
2176
+ // }.
2177
+ echo 'if(!nextURL_' . esc_js( $_REQUEST['fts_dynamic_name'] ) . ' || nextURL_' . esc_js( $_REQUEST['fts_dynamic_name'] ) . ' == "no more"){';
2178
+ if ( 'reviews' === $fb_shortcode['type'] ) {
2179
+ echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").replaceWith(\'<div class="fts-fb-load-more no-more-posts-fts-fb">' . esc_html( $fb_no_more_reviews_text ) . '</div>\');';
2180
+ } elseif ( 'videos' === $fb_shortcode['type'] ) {
2181
+ echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").replaceWith(\'<div class="fts-fb-load-more no-more-posts-fts-fb">' . esc_html( $fb_no_more_videos_text ) . '</div>\');';
2182
+ } else {
2183
+ echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").replaceWith(\'<div class="fts-fb-load-more no-more-posts-fts-fb">' . esc_html( $fb_no_more_photos_text ) . '</div>\');';
2184
+ }
2185
+
2186
+ echo ' jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").removeAttr("id");';
2187
+ echo 'jQuery(".' . esc_js( $fts_dynamic_class_name ) . '").unbind("scroll");';
2188
+ echo '}';
2189
+ } else {
2190
+ if ( isset( $fb_shortcode['video_album'] ) && 'yes' === $fb_shortcode['video_album'] ) {
2191
+ echo 'var result = jQuery(data).insertBefore( jQuery("#output_' . esc_js( $fts_dynamic_name ) . '") );';
2192
+ echo 'var result = jQuery(".feed_dynamic_' . esc_js( $fts_dynamic_name ) . '_album_photos").append(data).filter("#output_' . esc_js( $fts_dynamic_name ) . '").html();';
2193
+ } else {
2194
+ echo 'var result = jQuery("#output_' . esc_js( $fts_dynamic_name ) . '").append(data).filter("#output_' . esc_js( $fts_dynamic_name ) . '").html();';
2195
+ }
2196
+ echo 'jQuery("#output_' . esc_js( $fts_dynamic_name ) . '").html(result);';
2197
+ echo 'if(!nextURL_' . esc_js( $_REQUEST['fts_dynamic_name'] ) . ' || nextURL_' . esc_js( $_REQUEST['fts_dynamic_name'] ) . ' == "no more"){';
2198
+ // Reviews.
2199
+ if ( 'reviews' === $fb_shortcode['type'] ) {
2200
+ echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").replaceWith(\'<div class="fts-fb-load-more no-more-posts-fts-fb">' . esc_html( $fb_no_more_reviews_text ) . '</div>\');';
2201
+ } else {
2202
+ echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").replaceWith(\'<div class="fts-fb-load-more no-more-posts-fts-fb">' . esc_html( $fb_no_more_posts_text ) . '</div>\');';
2203
+ }
2204
+ echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").removeAttr("id");';
2205
+ echo 'jQuery(".' . esc_js( $fts_dynamic_class_name ) . '").unbind("scroll");';
2206
+ echo '}';
2207
+
2208
+ }
2209
+ echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").html("' . esc_html( $fb_load_more_text ) . '");';
2210
+ // jQuery("#loadMore_'.$fts_dynamic_name.'").removeClass("flip360-fts-load-more");.
2211
+ echo 'jQuery("#loadMore_' . esc_js( $fts_dynamic_name ) . '").removeClass("fts-fb-spinner");';
2212
+ if ( isset( $fb_shortcode['popup'] ) && 'yes' === $fb_shortcode['popup'] ) {
2213
+ // We return this function again otherwise the popup won't work correctly for the newly loaded items.
2214
+ echo 'jQuery.fn.slickFacebookPopUpFunction();';
2215
+ }
2216
+ // Reload the share each funcion otherwise you can't open share option..
2217
+ echo 'jQuery.fn.ftsShare();slickremixImageResizingFacebook2();slickremixImageResizingFacebook3();';
2218
+
2219
+ echo '}';
2220
+ echo '});';
2221
+ // end of ajax().
2222
+ echo 'return false;';
2223
+ // string $scrollMore is at top of this js script. acception for scroll option closing tag.
2224
+ if ( 'autoscroll' === $fb_shortcode['loadmore'] ) {
2225
+ echo '}';
2226
+ // end of scroll ajax load.
2227
+ }
2228
+ echo '});';
2229
+ // end of document.ready.
2230
+ echo '});';
2231
+ // end of form.submit.
2232
+ echo '</script>';
2233
+ }
2234
+ // End Check.
2235
+ // main closing div not included in ajax check so we can close the wrap at all times.
2236
+ // Make sure it's not ajaxing.
2237
+ if ( ! isset( $_GET['load_more_ajaxing'] ) ) {
2238
+ $fts_dynamic_name = $_REQUEST['fts_dynamic_name'];
2239
+ // this div returns outputs our ajax request via jquery appenc html from above style="display:nonee;".
2240
+ echo '<div id="output_' . esc_attr( $fts_dynamic_name ) . '" class="fts-fb-load-more-output"></div>';
2241
+ if ( ( is_plugin_active( 'feed-them-premium/feed-them-premium.php' ) && 'reviews' !== $fb_shortcode['type'] || is_plugin_active( 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php' ) && 'reviews' === $fb_shortcode['type'] ) && 'autoscroll' === $fb_shortcode['loadmore'] ) {
2242
+ echo '<div id="loadMore_' . esc_attr( $fts_dynamic_name ) . '" class="fts-fb-load-more fts-fb-autoscroll-loader">Facebook</div>';
2243
+ }
2244
+ }
2245
+ }
2246
+ // end of if loadmore is button or autoscroll.
2247
+ }
2248
+ // end fts_facebook_loadmore().
2249
+
2250
+ /**
2251
+ * Random String
2252
+ *
2253
+ * Create a random string
2254
+ *
2255
+ * @param string $length How many character to randomize.
2256
+ * @return mixed
2257
+ * @since 1.9.6
2258
+ */
2259
+ public function fts_rand_string( $length = 10 ) {
2260
+ $characters = 'abcdefghijklmnopqrstuvwxyz';
2261
+ $characters_length = strlen( $characters );
2262
+ $random_string = '';
2263
+ for ( $i = 0; $i < $length; $i++ ) {
2264
+ $random_string .= $characters[ wp_rand( 0, $characters_length - 1 ) ];
2265
+ }
2266
+
2267
+ return $random_string;
2268
+ }
2269
  }//end class
feeds/instagram/class-fts-instagram-feed.php CHANGED
@@ -523,7 +523,7 @@ class FTS_Instagram_Feed extends feed_them_social_functions {
523
  $business_cache = 'instagram_business_cache' . $instagram_id . '_num' . $pics_count . '';
524
 
525
  // this is not getting cached currently
526
- $instagram_data_array['user_info'] = 'https://graph.facebook.com/v3.2/' . $instagram_id . '?fields=biography%2Cid%2Cig_id%2Cfollowers_count%2Cfollows_count%2Cmedia_count%2Cname%2Cprofile_picture_url%2Cusername%2Cwebsite&access_token=' . $fts_instagram_access_token_final;
527
 
528
  // This only returns the next url and a list of media ids. We then have to loop through the ids and make a call to get each ids data from the API.
529
  $instagram_data_array['data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : 'https://graph.facebook.com/' . $instagram_id . '/media?limit=' . $pics_count . '&access_token=' . $fts_instagram_access_token_final;
523
  $business_cache = 'instagram_business_cache' . $instagram_id . '_num' . $pics_count . '';
524
 
525
  // this is not getting cached currently
526
+ $instagram_data_array['user_info'] = 'https://graph.facebook.com/v3.3/' . $instagram_id . '?fields=biography%2Cid%2Cig_id%2Cfollowers_count%2Cfollows_count%2Cmedia_count%2Cname%2Cprofile_picture_url%2Cusername%2Cwebsite&access_token=' . $fts_instagram_access_token_final;
527
 
528
  // This only returns the next url and a list of media ids. We then have to loop through the ids and make a call to get each ids data from the API.
529
  $instagram_data_array['data'] = isset( $_REQUEST['next_url'] ) ? esc_url_raw( $_REQUEST['next_url'] ) : 'https://graph.facebook.com/' . $instagram_id . '/media?limit=' . $pics_count . '&access_token=' . $fts_instagram_access_token_final;
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: slickremix, slickchris
3
  Tags: Facebook, Instagram, Twitter, YouTube, Feed
4
  Requires at least: 3.6.0
5
- Tested up to: 5.7.0
6
- Stable tag: 2.9.5
7
  License: GPLv2 or later
8
 
9
  Display a Custom Facebook feed, Instagram feed, Twitter feed, and YouTube feed on pages, posts or widgets.
@@ -72,6 +72,9 @@ Feed Them Social was Developed By SlickRemix --> [https://www.slickremix.com/](h
72
  * Log into WordPress dashboard then click **Plugins** > **Add new** > Then under the title "Install Plugins" click **Upload** > **choose the zip** > **Activate the plugin!**
73
 
74
  == Changelog ==
 
 
 
75
  = Version 2.9.5 Monday, April 12th, 2021 =
76
  * FIX: PHP 8.0 compatible.
77
 
2
  Contributors: slickremix, slickchris
3
  Tags: Facebook, Instagram, Twitter, YouTube, Feed
4
  Requires at least: 3.6.0
5
+ Tested up to: 5.7.1
6
+ Stable tag: 2.9.6
7
  License: GPLv2 or later
8
 
9
  Display a Custom Facebook feed, Instagram feed, Twitter feed, and YouTube feed on pages, posts or widgets.
72
  * Log into WordPress dashboard then click **Plugins** > **Add new** > Then under the title "Install Plugins" click **Upload** > **choose the zip** > **Activate the plugin!**
73
 
74
  == Changelog ==
75
+ = Version 2.9.6 Friday, May 7th, 2021 =
76
+ * FIX: FACEBOOK FEED: 3.2 API depreciation
77
+
78
  = Version 2.9.5 Monday, April 12th, 2021 =
79
  * FIX: PHP 8.0 compatible.
80