PluginProbe ʕ •ᴥ•ʔ
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress / 4.1.1
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress v4.1.1
4.8.1 trunk 1.0 1.1 1.12.1 1.2.3 1.2.4 1.2.5 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.5 1.5.1 1.5.2 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.4.1 1.6.5 1.6.5.1 1.6.6 1.6.6.1 1.6.6.2 1.6.6.3 1.6.7 1.6.7.1 1.6.8 1.6.8.1 1.6.8.2 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.9.0 1.9.1 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.8.1 1.9.9 1.9.9.1 1.9.9.2 1.9.9.3 2.0 2.0.1 2.1 2.1.1 2.1.2 2.1.3 2.10 2.11 2.11.1 2.12 2.12.1 2.12.2 2.12.3 2.12.4 2.13 2.14 2.14.1 2.15 2.15.1 2.16 2.16.1 2.17 2.17.1 2.18 2.18.1 2.18.2 2.18.3 2.19 2.19.1 2.19.2 2.19.3 2.2 2.2.1 2.3 2.3.1 2.3.10 2.3.2 2.3.3 2.3.4 2.3.6 2.3.7 2.3.8 2.3.9 2.4 2.4.1 2.4.1.1 2.4.1.2 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5 2.5.1 2.5.2 2.6 2.6.1 2.6.2 2.6.3 2.6.4 2.7 2.7.1 2.7.2 2.8 2.9 2.9.1 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.1 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.7.5 4.7.6 4.7.7
custom-facebook-feed / inc / CFF_Shortcode.php
custom-facebook-feed / inc Last commit date
Admin 4 years ago Builder 4 years ago Helpers 5 years ago CFF_Autolink.php 5 years ago CFF_Blocks.php 4 years ago CFF_Cache.php 4 years ago CFF_Education.php 5 years ago CFF_Elementor_Base.php 4 years ago CFF_Elementor_Widget.php 4 years ago CFF_Error_Reporter.php 4 years ago CFF_FB_Settings.php 4 years ago CFF_Feed_Elementor_Control.php 4 years ago CFF_Feed_Locator.php 4 years ago CFF_Feed_Pro.php 4 years ago CFF_GDPR_Integrations.php 4 years ago CFF_Group_Posts.php 4 years ago CFF_HTTP_Request.php 4 years ago CFF_Oembed.php 4 years ago CFF_Parse.php 4 years ago CFF_Resizer.php 4 years ago CFF_Response.php 4 years ago CFF_Shortcode.php 4 years ago CFF_Shortcode_Display.php 4 years ago CFF_SiteHealth.php 4 years ago CFF_Utils.php 4 years ago CFF_View.php 4 years ago Custom_Facebook_Feed.php 4 years ago SB_Facebook_Data_Encryption.php 4 years ago SB_Facebook_Data_Manager.php 4 years ago
CFF_Shortcode.php
2267 lines
1 <?php
2 /**
3 * Custom Facebook Feed Main Shortcode Class
4 *
5 * @since 2.19
6 */
7
8 namespace CustomFacebookFeed;
9
10 use CustomFacebookFeed\Builder\CFF_Source;
11 use CustomFacebookFeed\SB_Facebook_Data_Encryption;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 die( '-1' );
15 }
16
17 class CFF_Shortcode extends CFF_Shortcode_Display{
18
19 /**
20 * @var Class
21 */
22 protected $fb_feed_settings;
23
24 /**
25 * @var array
26 */
27 protected $atts;
28
29 /**
30 * @var array
31 */
32 protected $options;
33
34 /**
35 * @var id
36 */
37 protected $page_id;
38
39 /**
40 * @var string
41 */
42 protected $access_token;
43
44 /**
45 * @var string
46 */
47 protected $feed_id;
48
49
50 /**
51 * Shortcode constructor
52 *
53 * @since 2.19
54 */
55 public function __construct(){
56 $this->init();
57 }
58
59
60
61 /**
62 * Init.
63 *
64 * @since 2.19
65 */
66 public function init(){
67 add_shortcode('custom-facebook-feed', array($this, 'display_cff'));
68 }
69
70
71 /**
72 * Get JSON data
73 *
74 * Returns a list of posts JSON form the FaceBook API API
75 *
76 * @since 2.19
77 * @return JSON OBJECT
78 */
79 public function get_feed_json( $graph_query, $cff_post_limit, $cff_locale, $cff_show_access_token, $cache_seconds, $cff_cache_time, $show_posts_by, $data_att_html ){
80 //Is it SSL?
81 $cff_ssl = is_ssl() ? '&return_ssl_resources=true' : '';
82 $attachments_desc = ( $this->atts['salesposts'] == 'true' ) ? '' : ',description';
83 $story_tags = ( $this->atts['storytags'] == 'true' ) ? '' : ',story_tags';
84
85 $cff_posts_json_url = 'https://graph.facebook.com/v4.0/' . $this->page_id . '/' . $graph_query . '?fields=id,updated_time,from{picture,id,name,link},message,message_tags,story'. $story_tags .',status_type,created_time,backdated_time,call_to_action,attachments{title'. $attachments_desc . ',media_type,unshimmed_url,target{id},media{source}}&access_token=' . $this->access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale . $cff_ssl;
86 //Create the transient name
87 //Split the Page ID in half and stick it together so we definitely have the beginning and end of it
88 $trans_page_id = substr($this->page_id, 0, 16) . substr($this->page_id, -15);
89 $transient_name = 'cff_' . substr($graph_query, 0, 1) . '_' . $trans_page_id . substr($cff_post_limit, 0, 3) . substr($show_posts_by, 0, 2) . substr($cff_locale, 0, 2);
90 //Limit to 45 chars max
91 $transient_name = substr($transient_name, 0, 45);
92
93 $posts_json = CFF_Utils::cff_get_set_cache( $cff_posts_json_url, $transient_name, $cff_cache_time, $cache_seconds, $data_att_html, false, $this->access_token, true );
94
95 return json_decode($posts_json);
96 }
97
98
99 /**
100 * Get Graph Query & (Show only by others)
101 *
102 * Getting the FaceBook Graph Query depending on the settings
103 *
104 * @since 2.19
105 * @return array
106 */
107 public function get_graph_query($show_posts_by, $cff_is_group){
108 //Use posts? or feed?
109 $old_others_option = get_option('cff_show_others'); //Use this to help depreciate the old option
110 $show_others = $this->atts['others'];
111 $graph_query = 'posts';
112 $cff_show_only_others = false;
113 //If 'others' shortcode option is used then it overrides any other option
114 if ($show_others || $old_others_option == 'on') {
115 //Show posts by everyone
116 if ( $old_others_option == 'on' || $show_others == 'on' || $show_others == 'true' || $show_others == true || $cff_is_group ) $graph_query = 'feed';
117 //Only show posts by me
118 if ( $show_others == 'false' ) $graph_query = 'posts';
119 } else {
120 //Else use the settings page option or the 'showpostsby' shortcode option
121 //Only show posts by me
122 if ( $show_posts_by == 'me' ) $graph_query = 'posts';
123 //Show posts by everyone
124 if ( $show_posts_by == 'others' || $cff_is_group ) $graph_query = 'feed';
125 //Show posts ONLY by others
126 if ( $show_posts_by == 'onlyothers' && !$cff_is_group ) {
127 $graph_query = 'visitor_posts';
128 $cff_show_only_others = true;
129 }
130 }
131
132 return [
133 'graph_query' => $graph_query,
134 'cff_show_only_others' => $cff_show_only_others
135 ];
136
137 }
138
139
140 /**
141 * Get Posts Limit
142 *
143 * Getting the FaceBook Graph Query depending on the settings
144 *
145 * @since 2.19
146 * @return int
147 */
148 public function get_post_limit($show_posts){
149 $cff_post_limit = $this->atts['limit'];
150 if ( isset($cff_post_limit) && $cff_post_limit !== '' ) {
151 $cff_post_limit = $cff_post_limit;
152 } else {
153 if( intval($show_posts) >= 50 ) $cff_post_limit = intval(intval($show_posts) + 7);
154 if( intval($show_posts) < 50 ) $cff_post_limit = intval(intval($show_posts) + 5);
155 if( intval($show_posts) < 25 ) $cff_post_limit = intval(intval($show_posts) + 4);
156 if( intval($show_posts) < 10 ) $cff_post_limit = intval(intval($show_posts) + 3);
157 if( intval($show_posts) < 6 ) $cff_post_limit = intval(intval($show_posts) + 2);
158 if( intval($show_posts) < 2 ) $cff_post_limit = intval(intval($show_posts) + 1);
159 }
160 if( $cff_post_limit >= 100 ) $cff_post_limit = 100;
161 return $cff_post_limit;
162 }
163
164
165 function cff_get_shortcode_data_attribute_html( $feed_options ) {
166
167 //If an access token is set in the shortcode then set "use own access token" to be enabled
168 if( isset($feed_options['accesstoken']) ){
169 //Add an encryption string to protect token
170 if ( strpos($feed_options['accesstoken'], ',') !== false ) {
171 //If there are multiple tokens then just add the string after the colon to avoid having to de/reconstruct the array
172 $feed_options['accesstoken'] = str_replace(":", ":02Sb981f26534g75h091287a46p5l63", $feed_options['accesstoken']);
173 } else {
174 //Add an encryption string to protect token
175 $feed_options['accesstoken'] = substr_replace($feed_options['accesstoken'], '02Sb981f26534g75h091287a46p5l63', 25, 0);
176 }
177 $feed_options['ownaccesstoken'] = 'on';
178 }
179
180 if( !empty($feed_options) ){
181 $json_data = '{';
182 $i = 0;
183 $len = count($feed_options);
184 foreach( $feed_options as $key => $value ) {
185 if ($i == $len - 1) {
186 $json_data .= '&quot;'.$key.'&quot;: &quot;'.$value.'&quot;';
187 } else {
188 $json_data .= '&quot;'.$key.'&quot;: &quot;'.$value.'&quot;, ';
189 }
190 $i++;
191 }
192 $json_data .= '}';
193
194 return $json_data;
195 }
196
197 }
198
199 function cff_get_processed_options($feed_options){
200 $feed_id = empty( $feed_options['feed'] ) ? 'default' : intval( $feed_options['feed'] );
201 $feed_options = $this->get_settings_for_feed( $feed_options );
202
203 if ( empty( $feed_options ) ) {
204 $options = get_option('cff_style_settings');
205 $fdo = new CFF_FB_Settings($feed_options, $options);
206 $feed_options = $fdo->get_settings();
207 $feed_options['feederror'] = $feed_id;
208 return $feed_options;
209 }
210
211 $page_id = $feed_options['id'];
212 $cff_facebook_string = 'facebook.com';
213 ( stripos($page_id, $cff_facebook_string) !== false) ? $cff_page_id_url_check = true : $cff_page_id_url_check = false;
214 if ( $cff_page_id_url_check === true ) {
215 //Remove trailing slash if exists
216 $page_id = preg_replace('{/$}', '', $page_id);
217 //Get last part of url
218 $page_id = substr( $page_id, strrpos( $page_id, '/' )+1 );
219 }
220 //If the Page ID contains a query string at the end then remove it
221 if ( stripos( $page_id, '?') !== false ) $page_id = substr($page_id, 0, strrpos($page_id, '?'));
222
223 //Always remove slash from end of Page ID
224 $page_id = preg_replace('{/$}', '', $page_id);
225
226 //Update the page ID in the feed options array for use everywhere
227 $feed_options['id'] = $page_id;
228
229
230 //If an 'account' is specified then use that instead of the Page ID/token from the settings
231 $cff_account = trim($feed_options['account']);
232
233 if( !empty( $cff_account ) ){
234 $cff_connected_accounts = get_option('cff_connected_accounts');
235 if( !empty($cff_connected_accounts) ){
236
237 //Replace both single and double quotes before decoding
238 $cff_connected_accounts = str_replace('\"','"', $cff_connected_accounts);
239 $cff_connected_accounts = str_replace("\'","'", $cff_connected_accounts);
240
241 $cff_connected_accounts = json_decode( $cff_connected_accounts );
242
243 if ( isset( $cff_account ) && is_object( $cff_connected_accounts ) ) {
244 //Grab the ID and token from the connected accounts setting
245 if( isset( $cff_connected_accounts->{ $cff_account } ) ){
246 $feed_options['id'] = $cff_connected_accounts->{ $cff_account }->{'id'};
247 $feed_options['accesstoken'] = $cff_connected_accounts->{ $cff_account }->{'accesstoken'};
248 }
249
250 }
251
252 //Replace the encryption string in the Access Token
253 if (strpos($feed_options['accesstoken'], '02Sb981f26534g75h091287a46p5l63') !== false) {
254 $feed_options['accesstoken'] = str_replace("02Sb981f26534g75h091287a46p5l63","",$feed_options['accesstoken']);
255 }
256 }
257 }
258
259 //Replace the encryption string in the Access Token
260 if (strpos($feed_options['accesstoken'], '02Sb981f26534g75h091287a46p5l63') !== false) {
261 $feed_options['accesstoken'] = str_replace("02Sb981f26534g75h091287a46p5l63","",$feed_options['accesstoken']);
262 }
263 $cff_connected_accounts = get_option('cff_connected_accounts');
264 if(!empty($cff_connected_accounts)){
265 $connected_accounts = (array)json_decode(stripcslashes($cff_connected_accounts));
266 if(array_key_exists($feed_options['id'], $connected_accounts)){
267 $feed_options['pagetype'] = $connected_accounts[$feed_options['id']]->pagetype;
268 }
269 }
270
271 if ( ! empty( $feed_options['feedlayout'] ) ) {
272 if ( $feed_options['feedlayout'] === 'list' ) {
273 $feed_options['cols'] = 1;
274 $feed_options['colsmobile'] = 1;
275 $feed_options['colstablet'] = 1;
276 $feed_options['masonrycols'] = 1;
277 $feed_options['masonrycolsmobile'] = 1;
278 } elseif ( $feed_options['feedlayout'] === 'masonry' ) {
279 $feed_options['masonrycols'] = $feed_options['cols'] ;
280 $feed_options['masonrycolsmobile'] = $feed_options['colsmobile'];
281 }
282 }
283
284 return $feed_options;
285 }
286
287 /**
288 * Display.
289 * The main Shortcode display
290 *
291 * @since 2.19
292 */
293 public function display_cff($atts) {
294 do_action( 'cff_before_display_facebook' );
295 $this->options = get_option('cff_style_settings');
296 $data_att_html = $this->cff_get_shortcode_data_attribute_html( $atts );
297 $feed_id = empty( $atts['feed'] ) ? 'default' : intval( $atts['feed'] );
298 $feed_options = $this->get_settings_for_feed( $atts );
299
300 if ( empty( $feed_options ) ) {
301 $this->fb_feed_settings = new CFF_FB_Settings($atts, $this->options);
302 $this->atts = $this->fb_feed_settings->get_settings();
303 $id_and_token = $this->fb_feed_settings->get_id_and_token();
304 $this->page_id = $id_and_token['id'];
305
306 $encryption = new SB_Facebook_Data_Encryption();
307 $this->access_token = $encryption->decrypt($id_and_token['token']) ? $encryption->decrypt($id_and_token['token']) : $id_and_token['token'];
308
309 $this->atts = $this->cff_get_processed_options( $this->atts );
310
311 } else {
312 if ( ! empty( $feed_options['feedlayout'] ) ) {
313 if ( $feed_options['feedlayout'] === 'list' ) {
314 $feed_options['cols'] = 1;
315 $feed_options['colsmobile'] = 1;
316 $feed_options['colstablet'] = 1;
317 $feed_options['masonrycols'] = 1;
318 $feed_options['masonrycolsmobile'] = 1;
319 } elseif ( $feed_options['feedlayout'] === 'masonry' ) {
320 $feed_options['masonrycols'] = $feed_options['cols'] ;
321 $feed_options['masonrycolsmobile'] = $feed_options['colsmobile'];
322 }
323 }
324
325
326 $this->atts = $feed_options;
327 }
328
329 $this->cff_add_translations();
330 #var_dump($this->atts);
331
332 //Vars for the templates
333 $atts = $this->atts;
334 $options = $this->options;
335 $access_token = $this->access_token;
336 $page_id = $this->page_id;
337
338 if ( $atts['cff_enqueue_with_shortcode'] === 'on' || $atts['cff_enqueue_with_shortcode'] === 'true' ) {
339 wp_enqueue_style( 'cff' );
340 wp_enqueue_script( 'cffscripts' );
341 }
342
343 $palette = '';
344 $custom_palette_class = '';
345 $doing_custom_styles = false;
346
347 if ( ! empty( $this->atts['colorpalette'] ) ) {
348 switch ( $this->atts['colorpalette'] ) {
349 case 'dark' :
350 $palette = 'cff-dark ';
351 break;
352 case 'light' :
353 $palette = 'cff-light ';
354 break;
355 case 'custom' :
356 $doing_custom_styles = true;
357 $custom_palette_class = 'cff-palette-' . $feed_id . ' ';
358 break;
359 default:
360 $palette = '';
361 }
362 }
363
364 $this->atts['paletteclass'] = $palette . $custom_palette_class;
365
366 /********** GENERAL **********/
367 $cff_page_type = $this->atts[ 'pagetype' ];
368 ($cff_page_type == 'group') ? $cff_is_group = true : $cff_is_group = false;
369
370
371 $cff_show_author = $this->atts[ 'showauthornew' ];
372 $cff_cache_time = $this->atts[ 'cachetime' ];
373 $cff_locale = $this->atts[ 'locale' ];
374 if( empty($cff_locale) || !isset($cff_locale) || $cff_locale == '' ) $cff_locale = 'en_US';
375 if(!isset($cff_cache_time) || $cff_cache_time == '' ) $cff_cache_time = 0;
376 $cff_cache_time_unit = $this->atts[ 'cacheunit' ];
377
378 $like_box = CFF_Utils::print_template_part( 'likebox', get_defined_vars());
379
380
381 if($cff_cache_time == 'nocaching') $cff_cache_time = 0;
382
383 //Like box
384 $cff_like_box_position = $this->atts[ 'likeboxpos' ];
385 $cff_like_box_outside = CFF_Utils::check_if_on($this->atts[ 'likeboxoutside' ]);
386 //Open links in new window?
387 $target = 'target="_blank"';
388 /********** LAYOUT **********/
389 $cff_show_author = $this->check_show_section( 'author' );
390 $cff_show_text = $this->check_show_section( 'text' );
391 $cff_show_desc = $this->check_show_section( 'desc' );
392 $cff_show_shared_links = $this->check_show_section( 'sharedlink' );
393 $cff_show_date = $this->check_show_section( 'date' );
394 $cff_show_media = $this->check_show_section( 'media' );
395 $cff_show_media_link = $this->check_show_section( 'medialink' );
396 $cff_show_event_title = $this->check_show_section( 'eventtitle' );
397 $cff_show_event_details = $this->check_show_section( 'eventdetail' );
398 $cff_show_meta = $this->check_show_section( 'social' );
399 $cff_show_link = $this->check_show_section( ',link' );
400 $cff_show_like_box = isset( $this->atts['showlikebox'] ) ? CFF_Utils::check_if_on( $this->atts['showlikebox'] ) : false;
401
402 //Set free version to thumb layout by default as layout option not available on settings page
403 $cff_preset_layout = 'thumb';
404
405 //If the old shortcode option 'showauthor' is being used then apply it
406 $cff_show_author_old = $this->atts[ 'showauthor' ];
407 if( $cff_show_author_old == 'false' ) $cff_show_author = false;
408 if( $cff_show_author_old == 'true' ) $cff_show_author = true;
409
410 //See Less text
411 $cff_posttext_link_color = str_replace('#', '', $this->atts['textlinkcolor']);
412 $cff_title_link = CFF_Utils::check_if_on( $this->atts['textlink'] );
413
414 //Description Style
415 $cff_body_styles = $this->get_style_attribute( 'body_description' );
416
417 //Shared link box
418 $cff_disable_link_box = CFF_Utils::check_if_on( $this->atts['disablelinkbox'] );
419
420 $cff_link_box_styles = $cff_disable_link_box ? '' : $this->get_style_attribute( 'link_box' );
421
422 //Date
423 $cff_date_position = ( !isset( $this->atts[ 'datepos' ] ) ) ? 'below' : $this->atts[ 'datepos' ];
424
425
426 //Show Facebook link
427 $cff_link_to_timeline = $this->atts[ 'linktotimeline' ];
428
429 //Post Style settings
430 $cff_post_style = $this->atts['poststyle'];
431 $cff_post_bg_color_check = ($this->atts['postbgcolor'] !== '' && $this->atts['postbgcolor'] !== '#' && $cff_post_style != 'regular' ) ? true : false;
432 $cff_box_shadow = CFF_Utils::check_if_on( $this->atts['boxshadow'] ) && $cff_post_style == 'boxed';
433
434 //Text limits
435 $body_limit = $this->atts['desclength'];
436
437 //Get show posts attribute. If not set then default to 25
438 $show_posts = ( empty( $this->atts['num'] ) || $this->atts['num'] == 'undefined' ) ? 25 : $this->atts['num'];
439 $show_posts_number = isset( $this->atts['minnum'] ) ? $this->atts['minnum'] : $this->atts['num'];
440
441 //If the 'Enter my own Access Token' box is unchecked then don't use the user's access token, even if there's one in the field
442 get_option('cff_show_access_token') ? $cff_show_access_token = true : $cff_show_access_token = false;
443
444 //Check whether a Page ID has been defined
445 if ($this->page_id == '') {
446 if ( $this->using_legacy_feed( $feed_options ) ) {
447 echo "Please enter the Page ID of the Facebook feed you'd like to display. You can do this in either the Custom Facebook Feed plugin settings or in the shortcode itself. For example, [custom-facebook-feed id=YOUR_PAGE_ID_HERE].<br /><br />";
448 }
449 return false;
450 }
451
452 //Is it a restricted page?
453 $cff_restricted_page = CFF_Utils::check_if_on( $this->atts['restrictedpage'] );
454
455 $show_posts_by = $this->atts['showpostsby'];
456 $graph_info = $this->get_graph_query($show_posts_by, $cff_is_group);
457 $graph_query = $graph_info['graph_query'];
458 $cff_show_only_others = $graph_info['cff_show_only_others'];
459
460
461
462
463 // If Mobile and Desktop post nums are not the same, use minnum for API requests.
464 $mobile_num = isset( $this->atts['nummobile'] ) && (int)$this->atts['nummobile'] > 0 ? (int)$this->atts['nummobile'] : 0;
465 $desk_num = $show_posts;
466 if ( $desk_num < $mobile_num ) {
467 $this->atts['minnum'] = $mobile_num;
468 }
469
470 $show_posts = isset( $this->atts['minnum'] ) ? $this->atts['minnum'] : $show_posts;
471 $cff_post_limit = $this->get_post_limit($show_posts);
472
473 //If the number of posts is set to zero then don't show any and set limit to one
474 if ( ($show_posts == '0' || $show_posts == 0) && $show_posts !== ''){
475 $show_posts = 0;
476 $cff_post_limit = 1;
477 }
478
479
480 //Calculate the cache time in seconds
481 if($cff_cache_time_unit == 'minutes') $cff_cache_time_unit = 60;
482 if($cff_cache_time_unit == 'hours') $cff_cache_time_unit = 60*60;
483 if($cff_cache_time_unit == 'days') $cff_cache_time_unit = 60*60*24;
484 $cache_seconds = $cff_cache_time * $cff_cache_time_unit;
485
486
487
488
489
490 //Misc Settings
491 $cff_nofollow = CFF_Utils::check_if_on( $this->atts['nofollow'] );
492 ( $cff_nofollow ) ? $cff_nofollow = ' rel="nofollow noopener"' : $cff_nofollow = '';
493 $cff_nofollow_referrer = ' rel="nofollow noopener noreferrer"';
494
495 //If the number of posts is set to zero then don't show any and set limit to one
496 if ( ($this->atts['num'] == '0' || $this->atts['num'] == 0) && $this->atts['num'] !== ''){
497 $show_posts = 0;
498 $cff_post_limit = 1;
499 }
500
501 //***START FEED***
502 #$defined_vars = get_defined_vars();
503 $cff_content = '';
504
505 //Create CFF container HTML
506 $cff_content .= '<div class="cff-wrapper">';
507 $cff_style_class = $this->feed_style_class_compiler();
508 $cff_insider_style = $this->get_style_attribute( 'feed_wrapper_insider' );
509 $cff_feed_height = CFF_Utils::get_css_distance( $this->atts[ 'height' ] ) ;
510 //Feed header
511 $cff_show_header = CFF_Utils::check_if_on( $this->atts['showheader'] );
512 $cff_header_outside = CFF_Utils::check_if_on( $this->atts['headeroutside'] );
513 $cff_header_type = strtolower( $this->atts['headertype'] );
514 $cff_header = CFF_Utils::print_template_part( 'header', get_defined_vars(), $this);
515
516 //Add the page header to the outside of the top of feed
517 if ($cff_show_header && $cff_header_outside) $cff_content .= $cff_header;
518
519 //Add like box to the outside of the top of feed
520 if ($cff_like_box_position == 'top' && $cff_show_like_box && $cff_like_box_outside) $cff_content .= $like_box;
521
522
523 //Get Custom Class and Compiled CSS
524
525 $custom_wrp_class = !empty($cff_feed_height) ? ' cff-wrapper-fixed-height' : '';
526
527 $cff_content .= '<div class="cff-wrapper-ctn '.$custom_wrp_class.'" '.$cff_insider_style.'>';
528 $cff_content .= '<div id="cff" ' . $cff_style_class['cff_custom_class'] . ' ' . $cff_style_class['cff_feed_styles'] . ' ' . $cff_style_class['cff_feed_attributes'] . '>';
529
530 //Add the page header to the inside of the top of feed
531 if ($cff_show_header && !$cff_header_outside) $cff_content .= $cff_header;
532
533 //Add like box to the inside of the top of feed
534 if ($cff_like_box_position == 'top' && $cff_show_like_box && !$cff_like_box_outside) $cff_content .= $like_box;
535 //Limit var
536 $i_post = 0;
537
538 //Define array for post items
539 $cff_posts_array = array();
540 //ALL POSTS
541
542 $FBdata = $this->get_feed_json( $graph_query, $cff_post_limit, $cff_locale, $cff_show_access_token, $cache_seconds, $cff_cache_time, $show_posts_by, $data_att_html );
543 if( $cff_is_group ){
544 $cff_ssl = is_ssl() ? '&return_ssl_resources=true' : '';
545 $attachments_desc = ( $this->atts['salesposts'] == 'true' ) ? '' : ',description';
546 $cff_posts_json_url = 'https://graph.facebook.com/v4.0/' . $this->page_id . '/' . $graph_query . '?fields=id,updated_time,from{picture,id,name,link},message,message_tags,story,story_tags,status_type,created_time,backdated_time,call_to_action,attachments{title'. $attachments_desc . ',media_type,unshimmed_url,target{id},media{source}}&access_token=' . $this->access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale . $cff_ssl;
547 $this->atts['type'] = 'links_events_videos_photos_albums_statuses_';
548 $groups_post = new CFF_Group_Posts($this->page_id, $this->atts, $cff_posts_json_url, $data_att_html, false);
549 $groups_post_result = $groups_post->init_group_posts(json_encode($FBdata), false, $show_posts_number);
550 $posts_json = $groups_post_result['posts_json'];
551 $FBdata = json_decode($posts_json);
552 }
553
554
555 global $current_user;
556 $user_id = $current_user->ID;
557
558 //Print Pretty Message Error
559 $cff_content .= CFF_Utils::print_template_part( 'error-message', get_defined_vars());
560
561 $numeric_page_id = '';
562 if( !empty($FBdata->data) ){
563 if ( ($cff_show_only_others || $show_posts_by == 'others') && count($FBdata->data) > 0 ) {
564 //Get the numeric ID of the page so can compare it to the author of each post
565 $first_post_id = explode("_", $FBdata->data[0]->id);
566 $numeric_page_id = $first_post_id[0];
567 }
568 }
569
570 $posts_wrap_box_shadow_class = $cff_box_shadow && $this->atts['feedlayout'] === 'list' ? ' cff-posts-wrap-box-shadow' : '';
571 $cff_content .= '<div class="cff-posts-wrap'.$posts_wrap_box_shadow_class.'">';
572
573 //***STARTS POSTS LOOP***
574 if( isset($FBdata->data) ){
575 if ( ! \cff_main()->cff_error_reporter->are_critical_errors()
576 && isset( $this->atts['sources'] )
577 && is_array( $this->atts['sources'] ) ) {
578 foreach ( $this->atts['sources'] as $source ) {
579 if ( ! empty( $source['error'] ) ) {
580 \CustomFacebookFeed\Builder\CFF_Source::clear_error( $source['account_id'] );
581 }
582 }
583 }
584 foreach ($FBdata->data as $news )
585 {
586 //Explode News and Page ID's into 2 values
587 $PostID = '';
588 $cff_post_id = '';
589 if( isset($news->id) ){
590 $cff_post_id = $news->id;
591 $PostID = explode("_", $cff_post_id);
592 }
593
594 //Reassign variable changes from API v3.3 update
595 $news->link = isset($news->attachments->data[0]->unshimmed_url) ? $news->attachments->data[0]->unshimmed_url : '';
596 $news->description = isset($news->attachments->data[0]->description) ? $news->attachments->data[0]->description : '';
597 $news->object_id = isset($news->attachments->data[0]->target->id) ? $news->attachments->data[0]->target->id : '';
598 $news->source = isset($news->attachments->data[0]->media->source) ? $news->attachments->data[0]->media->source : '';
599 $news->name = isset($news->attachments->data[0]->title) ? $news->attachments->data[0]->title : '';
600 $news->caption = isset($news->attachments->data[0]->title) ? $news->attachments->data[0]->title : '';
601
602 //Check the post type
603 $cff_post_type = isset($news->attachments->data[0]->media_type) ? $news->attachments->data[0]->media_type : 'status';
604
605 if ($cff_post_type == 'link') {
606 isset($news->story) ? $story = $news->story : $story = '';
607 //Check whether it's an event
608 $event_link_check = "facebook.com/events/";
609 if( isset($news->link) ){
610 $event_link_check = CFF_Utils::stripos($news->link, $event_link_check);
611 if ( $event_link_check ) $cff_post_type = 'event';
612 }
613 }
614 $cff_show_links_type = true;
615 $cff_show_event_type = true;
616 $cff_show_video_type = true;
617 $cff_show_photos_type = true;
618 $cff_show_status_type = true;
619 $cff_show_albums_type = true;
620 $cff_events_only = false;
621 //Are we showing ONLY events?
622 if ($cff_show_event_type && !$cff_show_links_type && !$cff_show_video_type && !$cff_show_photos_type && !$cff_show_status_type) $cff_events_only = true;
623 //Should we show this post or not?
624 $cff_show_post = false;
625 switch ($cff_post_type) {
626 case 'link':
627 if ( $cff_show_links_type ) $cff_show_post = true;
628 break;
629 case 'event':
630 if ( $cff_show_event_type ) $cff_show_post = true;
631 break;
632 case 'video':
633 if ( $cff_show_video_type ) $cff_show_post = true;
634 break;
635 case 'swf':
636 if ( $cff_show_video_type ) $cff_show_post = true;
637 break;
638 case 'photo':
639 if ( $cff_show_photos_type ) $cff_show_post = true;
640 break;
641 case 'offer':
642 $cff_show_post = true;
643 break;
644 default:
645 //Check whether it's a status (author comment or like)
646 if ( $cff_show_status_type && !empty($news->message) ) $cff_show_post = true;
647 break;
648 }
649 //Is it a duplicate post?
650 if (!isset($prev_post_message)) $prev_post_message = '';
651 if (!isset($prev_post_link)) $prev_post_link = '';
652 if (!isset($prev_post_description)) $prev_post_description = '';
653 isset($news->message) ? $pm = $news->message : $pm = '';
654 isset($news->link) ? $pl = $news->link : $pl = '';
655 isset($news->description) ? $pd = $news->description : $pd = '';
656
657 if ( ($prev_post_message == $pm) && ($prev_post_link == $pl) && ($prev_post_description == $pd) ) $cff_show_post = false;
658
659 //Offset. If the post index ($i_post) is less than the offset then don't show the post
660 if( intval($i_post) < intval($this->atts['offset']) ){
661 $cff_show_post = false;
662 $i_post++;
663 }
664
665 //Check post type and display post if selected
666 if ( $cff_show_post ) {
667 //If it isn't then create the post
668 //Only create posts for the amount of posts specified
669 if( intval($this->atts['offset']) > 0 ){
670 //If offset is being used then stop after showing the number of posts + the offset
671 if ( $i_post == (intval($show_posts) + intval($this->atts['offset'])) ) break;
672 } else {
673 //Else just stop after the number of posts to be displayed is reached
674 if ( $i_post == $show_posts ) break;
675 }
676 $i_post++;
677 //********************************//
678 //***COMPILE SECTION VARIABLES***//
679 //********************************//
680 //Set the post link
681 isset($news->link) ? $link = htmlspecialchars($news->link) : $link = '';
682 //Is it a shared album?
683 $shared_album_string = 'shared an album:';
684 isset($news->story) ? $story = $news->story : $story = '';
685 $shared_album = CFF_Utils::stripos($story, $shared_album_string);
686 if ( $shared_album ) {
687 $link = str_replace('photo.php?','media/set/?',$link);
688 }
689 //Check the post type
690 isset($cff_post_type) ? $cff_post_type = $cff_post_type : $cff_post_type = '';
691 if ($cff_post_type == 'link') {
692 isset($news->story) ? $story = $news->story : $story = '';
693 //Check whether it's an event
694 $event_link_check = "facebook.com/events/";
695 //Make sure URL doesn't include 'permalink' as that indicates someone else sharing a post from within an event (eg: https://www.facebook.com/events/617323338414282/permalink/617324268414189/) and the event ID is then not retrieved properly from the event URL as it's formatted like so: facebook.com/events/EVENT_ID/permalink/POST_ID
696 $event_link_check = CFF_Utils::stripos($news->link, $event_link_check);
697 $event_link_check_2 = CFF_Utils::stripos($news->link, "permalink/");
698 if ( $event_link_check && !$event_link_check_2 ) $cff_post_type = 'event';
699 }
700
701 //If it's an event then check whether the URL contains facebook.com
702 if(isset($news->link)){
703 if( CFF_Utils::stripos($news->link, "events/") && $cff_post_type == 'event' ){
704 //Facebook changed the event link from absolute to relative, and so if the link isn't absolute then add facebook.com to front
705 ( CFF_Utils::stripos($link, 'facebook.com') ) ? $link = $link : $link = 'https://facebook.com' . $link;
706 }
707 }
708
709 //Is it an album?
710 $cff_album = false;
711 if( isset($news->status_type) ){
712 if( $news->status_type == 'added_photos' ){
713 if( isset($news->attachments) ){
714 if( $news->attachments->data[0]->media_type == 'album' ) $cff_album = true;
715 }
716 }
717 }
718
719 //If there's no link provided then link to either the Facebook page or the individual status
720 if (empty($news->link)) {
721 if ($cff_link_to_timeline == true){
722 //Link to page
723 $link = 'https://facebook.com/' . $this->page_id;
724 } else {
725 //Link to status
726 $link = "https://www.facebook.com/" . $this->page_id . "/posts/" . $PostID[1];
727 }
728 }
729
730 $cff_date = CFF_Utils::print_template_part( 'item/date', get_defined_vars(), $this);
731
732
733
734
735 //Story/post text vars
736 $post_text = '';
737 $cff_story_raw = '';
738 $cff_message_raw = '';
739 $cff_name_raw = '';
740 $text_tags = '';
741 $post_text_story = '';
742 $post_text_message = '';
743
744 //STORY TAGS
745 $cff_post_tags = $this->atts[ 'posttags' ];
746
747 //Use the story
748 if (!empty($news->story)) {
749 $cff_story_raw = $news->story;
750 $post_text_story .= htmlspecialchars($cff_story_raw);
751
752
753 //Add message and story tags if there are any and the post text is the message or the story
754 if( $cff_post_tags && isset($news->story_tags) && !$cff_title_link){
755
756 $text_tags = $news->story_tags;
757
758 //Does the Post Text contain any html tags? - the & symbol is the best indicator of this
759 $cff_html_check_array = array('&lt;', '', '', '&quot;', '&amp;', '&gt;&gt;');
760
761 //always use the text replace method
762 if( CFF_Utils::cff_stripos_arr($post_text_story, $cff_html_check_array) !== false || ($cff_locale == 'el_GR' && count($news->story_tags) > 3) ) {
763
764 //Loop through the tags
765 foreach($text_tags as $message_tag ) {
766
767 ( isset($message_tag->id) ) ? $message_tag = $message_tag : $message_tag = $message_tag[0];
768
769 $tag_name = $message_tag->name;
770 $tag_link = '<a href="https://facebook.com/' . $message_tag->id . '">' . $message_tag->name . '</a>';
771
772 $post_text_story = str_replace($tag_name, $tag_link, $post_text_story);
773 }
774
775 } else {
776
777 //If it doesn't contain HTMl tags then use the offset to replace message tags
778 $message_tags_arr = array();
779
780 $tag = 0;
781 foreach($text_tags as $message_tag ) {
782 $tag++;
783 ( isset($message_tag->id) ) ? $message_tag = $message_tag : $message_tag = $message_tag[0];
784
785 isset($message_tag->type) ? $tag_type = $message_tag->type : $tag_type = '';
786
787 $message_tags_arr = CFF_Utils::cff_array_push_assoc(
788 $message_tags_arr,
789 $tag,
790 array(
791 'id' => $message_tag->id,
792 'name' => $message_tag->name,
793 'type' => isset($message_tag->type) ? $message_tag->type : '',
794 'offset' => $message_tag->offset,
795 'length' => $message_tag->length
796 )
797 );
798
799 }
800
801 //Keep track of the offsets so that if two tags have the same offset then only one is used. Need this as API 2.5 update changed the story_tag JSON format. A duplicate offset usually means '__ was with __ and 3 others'. We don't want to link the '3 others' part.
802 $cff_story_tag_offsets = '';
803 $cff_story_duplicate_offset = '';
804
805 //Check if there are any duplicate offsets. If so, assign to the cff_story_duplicate_offset var.
806 for($tag = count($message_tags_arr); $tag >= 1; $tag--) {
807 $c = (string)$message_tags_arr[$tag]['offset'];
808 if( strpos( $cff_story_tag_offsets, $c ) !== false && $c !== '0' ){
809 $cff_story_duplicate_offset = $c;
810 } else {
811 $cff_story_tag_offsets .= $c . ',';
812 }
813
814 }
815
816 for($tag = count($message_tags_arr); $tag >= 1; $tag--) {
817
818 //If the name is blank (aka the story tag doesn't work properly) then don't use it
819 if( $message_tags_arr[$tag]['name'] !== '' ) {
820
821 //If it's an event tag or it has the same offset as another tag then don't display it
822 if( $message_tags_arr[$tag]['type'] == 'event' || $message_tags_arr[$tag]['offset'] == $cff_story_duplicate_offset || $message_tags_arr[$tag]['type'] == 'page' ){
823 //Don't use the story tag in this case otherwise it changes '__ created an event' to '__ created an Name Of Event'
824 //Don't use the story tag if it's a page as it causes an issue when sharing a page: Smash Balloon Dev shared a Smash Balloon.
825 } else {
826 $b = '<a href="https://facebook.com/' . $message_tags_arr[$tag]['id'] . '" target="_blank">' . $message_tags_arr[$tag]['name'] . '</a>';
827 $c = $message_tags_arr[$tag]['offset'];
828 $d = $message_tags_arr[$tag]['length'];
829 $post_text_story = CFF_Utils::cff_mb_substr_replace( $post_text_story, $b, $c, $d);
830 }
831
832 }
833
834 }
835
836 } // end if/else
837
838 } //END STORY TAGS
839
840 }
841
842 //POST AUTHOR
843 $cff_author = CFF_Utils::print_template_part( 'item/author', get_defined_vars(), $this);
844
845 //Get the actual post text
846 //Which content should we use?
847 //Use the message
848 if (!empty($news->message)) {
849 $cff_message_raw = $news->message;
850
851 $post_text_message = htmlspecialchars($cff_message_raw);
852
853 //MESSAGE TAGS
854 //Add message and story tags if there are any and the post text is the message or the story
855 if( $cff_post_tags && isset($news->message_tags) && !$cff_title_link){
856
857 $text_tags = $news->message_tags;
858
859 //Does the Post Text contain any html tags? - the & symbol is the best indicator of this
860 $cff_html_check_array = array('&lt;', '', '', '&quot;', '&amp;', '&gt;&gt;', '&gt;');
861
862 //always use the text replace method
863 if( CFF_Utils::cff_stripos_arr($post_text_message, $cff_html_check_array) !== false ) {
864 //Loop through the tags
865 foreach($text_tags as $message_tag ) {
866
867 ( isset($message_tag->id) ) ? $message_tag = $message_tag : $message_tag = $message_tag[0];
868
869 $tag_name = $message_tag->name;
870 $tag_link = '<a href="https://facebook.com/' . $message_tag->id . '">' . $message_tag->name . '</a>';
871
872 $post_text_message = str_replace($tag_name, $tag_link, $post_text_message);
873 }
874
875 } else {
876 //If it doesn't contain HTMl tags then use the offset to replace message tags
877 $message_tags_arr = array();
878
879 $tag = 0;
880 foreach($text_tags as $message_tag ) {
881 $tag++;
882
883 ( isset($message_tag->id) ) ? $message_tag = $message_tag : $message_tag = $message_tag[0];
884
885 $message_tags_arr = CFF_Utils::cff_array_push_assoc(
886 $message_tags_arr,
887 $tag,
888 array(
889 'id' => $message_tag->id,
890 'name' => $message_tag->name,
891 'type' => isset($message_tag->type) ? $message_tag->type : '',
892 'offset' => $message_tag->offset,
893 'length' => $message_tag->length
894 )
895 );
896 }
897
898 //Keep track of the offsets so that if two tags have the same offset then only one is used. Need this as API 2.5 update changed the story_tag JSON format.
899 $cff_msg_tag_offsets = '';
900 $cff_msg_duplicate_offset = '';
901
902 //Check if there are any duplicate offsets. If so, assign to the cff_duplicate_offset var.
903 for($tag = count($message_tags_arr); $tag >= 1; $tag--) {
904 $c = (string)$message_tags_arr[$tag]['offset'];
905 if( strpos( $cff_msg_tag_offsets, $c ) !== false && $c !== '0' ){
906 $cff_msg_duplicate_offset = $c;
907 } else {
908 $cff_msg_tag_offsets .= $c . ',';
909 }
910 }
911
912 //Sort the array by the "offset" key as Facebook doesn't always return them in the correct order
913 usort($message_tags_arr, "CustomFacebookFeed\CFF_Utils::cffSortTags");
914
915 for($tag = count($message_tags_arr)-1; $tag >= 0; $tag--) {
916
917 //If the name is blank (aka the story tag doesn't work properly) then don't use it
918 if( $message_tags_arr[$tag]['name'] !== '' ) {
919
920 if( $message_tags_arr[$tag]['offset'] == $cff_msg_duplicate_offset ){
921 //If it has the same offset as another tag then don't display it
922 } else {
923 $b = '<a href="https://facebook.com/' . $message_tags_arr[$tag]['id'] . '">' . $message_tags_arr[$tag]['name'] . '</a>';
924 $c = $message_tags_arr[$tag]['offset'];
925 $d = $message_tags_arr[$tag]['length'];
926 $post_text_message = CFF_Utils::cff_mb_substr_replace( $post_text_message, $b, $c, $d);
927 }
928
929 }
930
931 }
932
933 } // end if/else
934
935 } //END MESSAGE TAGS
936
937 }
938
939
940 //Check to see whether it's an embedded video so that we can show the name above the post text if necessary
941 $cff_soundcloud = false;
942 $cff_is_video_embed = false;
943 if ($cff_post_type == 'video' || $cff_post_type == 'music'){
944 if( isset($news->source) && !empty($news->source) ){
945 $url = $news->source;
946 } else if ( isset($news->link) ) {
947 $url = $news->link;
948 } else {
949 $url = '';
950 }
951 //Embeddable video strings
952 $vimeo = 'vimeo';
953 $youtube = CFF_Utils::stripos($url, 'youtube');
954 $youtu = CFF_Utils::stripos($url, 'youtu');
955 $youtubeembed = CFF_Utils::stripos($url, 'youtube.com/embed');
956 $soundcloudembed = CFF_Utils::stripos($url, 'soundcloud.com');
957
958 //Check whether it's a youtube video
959 if($youtube || $youtu || $youtubeembed || (stripos($url, $vimeo) !== false)) {
960 $cff_is_video_embed = true;
961 }
962 //If it's soundcloud then add it into the shared link box at the bottom of the post
963 if( $soundcloudembed ) $cff_soundcloud = true;
964 }
965
966 //Add the story and message together
967 $post_text = '';
968
969 //DESCRIPTION
970 $cff_description = '';
971 if ( !empty($news->description) || !empty($news->caption) ) {
972 $description_text = '';
973
974 if ( !empty($news->description) ) {
975 $description_text = $news->description;
976 }
977
978 //Replace ellipsis char in description text
979 $raw_desc = $description_text;
980 $description_text = str_replace( '','...', $description_text);
981
982 //If the description is the same as the post text then don't show it
983 if( $raw_desc == $cff_story_raw || $raw_desc == $cff_message_raw || $raw_desc == $cff_name_raw ){
984 $cff_description = '';
985 } else {
986 //Add links and create HTML
987 $cff_description .= '<span class="cff-post-desc" '.$cff_body_styles.'>';
988
989 if ($cff_title_link) {
990 $cff_description_tagged = CFF_Utils::cff_wrap_span( htmlspecialchars($description_text) );
991 } else {
992 $cff_description_text = CFF_Autolink::cff_autolink( htmlspecialchars($description_text), $link_color=$cff_posttext_link_color );
993 $cff_description_tagged = CFF_Utils::cff_desc_tags($cff_description_text);
994 }
995
996 $cff_description .= $cff_description_tagged;
997 $cff_description .= ' </span>';
998 }
999
1000 if( $cff_post_type == 'event' || $cff_is_video_embed || $cff_soundcloud ) $cff_description = '';
1001 }
1002
1003 //Add the message
1004 if($cff_show_text) $post_text .= $post_text_message;
1005
1006 $post_text = apply_filters( 'cff_post_text', $post_text );
1007
1008 //If it's a shared video post then add the video name after the post text above the video description so it's all one chunk
1009 if ($cff_post_type == 'video'){
1010 if( !empty($cff_description) && $cff_description != '' ){
1011 if( (!empty($post_text) && $post_text != '') && !empty($cff_video_name) ) $post_text .= '<br /><br />';
1012 $post_text .= $cff_video_name;
1013 }
1014 }
1015
1016
1017 //Use the name if there's no other text, unless it's a shared link post as then it's already used as the shared link box title
1018 if ( !empty($news->name) && empty($news->message) && $cff_post_type != 'link' ) {
1019 $cff_name_raw = $news->name;
1020 $post_text = htmlspecialchars($cff_name_raw);
1021 }
1022
1023 //OFFER TEXT
1024 if ($cff_post_type == 'offer'){
1025 isset($news->story) ? $post_text = htmlspecialchars($news->story) . '<br /><br />' : $post_text = '';
1026 $post_text .= htmlspecialchars($news->name);
1027 }
1028
1029 //Add the description
1030 if( $cff_show_desc && $cff_post_type != 'offer' && $cff_post_type != 'link' ) $post_text .= $cff_description;
1031
1032 //Change the linebreak element if the text issue setting is enabled
1033 $cff_format_issue = CFF_Utils::check_if_on( $this->atts['textissue'] );
1034 $cff_linebreak_el = ( $cff_format_issue ) ? '<br />' : '<img class="cff-linebreak" />';
1035
1036 //EVENT
1037 $cff_event_has_cover_photo = false;
1038 $cff_event = '';
1039
1040
1041 //Create note
1042 if ($cff_post_type == 'note') {
1043 //Notes don't include any post text and so just replace the post text with the note content
1044 if($cff_show_text) $post_text = CFF_Utils::print_template_part( 'item/type/note', get_defined_vars(), $this);
1045 }
1046
1047 $cff_post_text = CFF_Utils::print_template_part( 'item/post-text', get_defined_vars(), $this);
1048
1049 //LINK
1050 //Display shared link
1051 $cff_shared_link = CFF_Utils::print_template_part( 'item/shared-link', get_defined_vars(), $this);
1052
1053 //Link to the Facebook post if it's a link or a video
1054 if($cff_post_type == 'link' || $cff_post_type == 'video') $link = "https://www.facebook.com/" . $this->page_id . "/posts/" . $PostID[1];
1055
1056
1057 //If it's a shared post then change the link to use the Post ID so that it links to the shared post and not the original post that's being shared
1058 if( isset($news->status_type) ){
1059 if( $news->status_type == 'shared_story' ) $link = "https://www.facebook.com/" . $cff_post_id;
1060 }
1061
1062 //Create post action links HTML
1063 $cff_link = CFF_Utils::print_template_part( 'item/post-link', get_defined_vars(), $this);
1064 /* MEDIA LINK */
1065 $cff_media_link = CFF_Utils::print_template_part( 'item/media-link', get_defined_vars(), $this);
1066 //**************************//
1067 //***CREATE THE POST HTML***//
1068 //**************************//
1069 //Start the container
1070 $cff_post_item = CFF_Utils::print_template_part( 'item/container', get_defined_vars(), $this);
1071
1072 //PUSH TO ARRAY
1073 $cff_posts_array = CFF_Utils::cff_array_push_assoc($cff_posts_array, $i_post, $cff_post_item);
1074
1075 } // End post type check
1076
1077 if (isset($news->message)) $prev_post_message = $news->message;
1078 if (isset($news->link)) $prev_post_link = $news->link;
1079 if (isset($news->description)) $prev_post_description = $news->description;
1080
1081 } // End the loop
1082 } //End isset($FBdata->data)
1083
1084 //Sort the array in reverse order (newest first)
1085 if(!$cff_is_group) ksort($cff_posts_array);
1086
1087 // End ALL POSTS
1088
1089
1090 //Output the posts array
1091 $p = 0;
1092 foreach ($cff_posts_array as $post ) {
1093 if ( $p == $show_posts ) break;
1094 $cff_content .= $post;
1095 $p++;
1096 }
1097
1098
1099 //Add the Like Box inside
1100 if ($cff_like_box_position == 'bottom' && $cff_show_like_box && !$cff_like_box_outside) $cff_content .= $like_box;
1101 /* Credit link */
1102
1103 $cff_content .= '</div>'; // End cff-posts-wrap
1104
1105 $cff_content .= CFF_Utils::print_template_part( 'credit', get_defined_vars());
1106
1107 //End the feed
1108 $cff_content .= '<input class="cff-pag-url" type="hidden" data-locatornonce="'.esc_attr( wp_create_nonce( 'cff-locator-nonce-' . get_the_ID() ) ) .'" data-cff-shortcode="'.$data_att_html.'" data-post-id="' . get_the_ID() . '" data-feed-id="'.$atts['id'].'">';
1109 $cff_content .= '</div></div><div class="cff-clear"></div>';
1110
1111 //Add the Like Box outside
1112 if ($cff_like_box_position == 'bottom' && $cff_show_like_box && $cff_like_box_outside) $cff_content .= $like_box;
1113
1114 //If the feed is loaded via Ajax then put the scripts into the shortcode itself
1115 $cff_content .= $this->ajax_loaded();
1116 $cff_content .= '</div>';
1117
1118 if ( $doing_custom_styles ) {
1119 $cff_content .= '<style type="text/css">'. "\n";
1120
1121 if ( ! empty( $this->atts['colorpalette'] )
1122 && $this->atts['colorpalette'] === 'custom' ) {
1123
1124 $wrap_selector = '#cff.' . $custom_palette_class;
1125
1126 if ( ! empty( $this->atts['custombgcolor1'] ) ) {
1127 $cff_content .= $wrap_selector . ' ' . '.cff-item,' . "\n";
1128 $cff_content .= $wrap_selector . ' ' . '.cff-item.cff-box,' . "\n";
1129 $cff_content .= $wrap_selector . ' ' . '.cff-item.cff-box:first-child,' . "\n";
1130 $cff_content .= $wrap_selector . ' ' . '.cff-album-item {' . "\n";
1131 $cff_content .= ' ' . 'background-color: ' . esc_attr( $this->atts['custombgcolor1'] ) . ';' ."\n";
1132 $cff_content .= '}' . "\n";
1133 }
1134
1135 if ( ! $cff_disable_link_box && ! empty( $this->atts['custombgcolor2'] ) ) {
1136 $cff_content .= $wrap_selector . ' ' . '.cff-view-comments,' . "\n";
1137 $cff_content .= $wrap_selector . ' ' . '.cff-load-more,' . "\n";
1138 $cff_content .= $wrap_selector . ' ' . '.cff-shared-link {' . "\n";
1139 $cff_content .= ' ' . 'background-color: ' . esc_attr( $this->atts['custombgcolor2'] ) . ';' ."\n";
1140 $cff_content .= '}' . "\n";
1141 }
1142
1143 if ( ! empty( $this->atts['textcolor1'] ) ) {
1144 $cff_content .= $wrap_selector . ' ' . '.cff-comment .cff-comment-text p,' . "\n";
1145 $cff_content .= $wrap_selector . ' ' . '.cff-album-info p,' . "\n";
1146 $cff_content .= $wrap_selector . ' ' . '.cff-story,' . "\n";
1147 $cff_content .= $wrap_selector . ' ' . '.cff-text {' . "\n";
1148 $cff_content .= ' ' . 'color: ' . esc_attr( $this->atts['textcolor1'] ) . ';' ."\n";
1149 $cff_content .= '}' . "\n";
1150 }
1151
1152 if ( ! empty( $this->atts['textcolor2'] ) ) {
1153 $cff_content .= $wrap_selector . ' ' . '.cff-comment-date,' . "\n";
1154 $cff_content .= $wrap_selector . ' ' . '.cff-text-link .cff-post-desc,' . "\n";
1155 $cff_content .= $wrap_selector . ' ' . '.cff-link-caption,' . "\n";
1156 $cff_content .= $wrap_selector . ' ' . '.cff-date {' . "\n";
1157 $cff_content .= ' ' . 'color: ' . esc_attr( $this->atts['textcolor2'] ) . ';' ."\n";
1158 $cff_content .= '}' . "\n";
1159 }
1160
1161 if ( ! empty( $this->atts['customlinkcolor'] ) ) {
1162 $cff_content .= $wrap_selector . ' ' . 'a,' . "\n";
1163 $cff_content .= $wrap_selector . ' ' . '.cff-post-links a,' . "\n";
1164 $cff_content .= $wrap_selector . ' ' . 'a {' . "\n";
1165 $cff_content .= ' ' . 'color: ' . esc_attr( $this->atts['customlinkcolor'] ) . ';' ."\n";
1166 $cff_content .= '}' . "\n";
1167 }
1168
1169 }
1170 $lightbox_selector = '#cff-lightbox-wrapper';
1171
1172 if ( ! empty( $this->atts['lightboxbgcolor'] ) ) {
1173 $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-dataContainer,' . "\n";
1174 $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-sidebar {' . "\n";
1175 $cff_content .= ' ' . 'background-color: ' . esc_attr( $this->atts['lightboxbgcolor'] ) . ';' ."\n";
1176 $cff_content .= '}' . "\n";
1177 }
1178
1179 if ( ! empty( $this->atts['lightboxtextcolor'] ) ) {
1180 $cff_content .= $lightbox_selector . ' ' . '.cff-author .cff-date,' . "\n";
1181 $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-closeContainer svg,' . "\n";
1182 $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-caption-text {' . "\n";
1183 $cff_content .= ' ' . 'color: ' . esc_attr( $this->atts['lightboxtextcolor'] ) . ';' ."\n";
1184 $cff_content .= '}' . "\n";
1185 }
1186
1187 if ( ! empty( $this->atts['lightboxlinkcolor'] ) ) {
1188 $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-caption-text a:link,' . "\n";
1189 $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-caption-text a:hover,' . "\n";
1190 $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-caption-text a:active,' . "\n";
1191 $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-caption-text a:visited,' . "\n";
1192 $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-facebook:link,' . "\n";
1193 $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-facebook:hover,' . "\n";
1194 $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-facebook:active,' . "\n";
1195 $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-facebook:visited,' . "\n";
1196 $cff_content .= $lightbox_selector . ' ' . 'a {' . "\n";
1197 $cff_content .= ' ' . 'color: ' . esc_attr( $this->atts['lightboxlinkcolor'] ) . ';' ."\n";
1198 $cff_content .= '}' . "\n";
1199 }
1200
1201 $cff_content .= '</style>';
1202
1203 }
1204
1205
1206 if( isset( $cff_posttext_link_color ) && !empty( $cff_posttext_link_color ) ) $cff_content .= '<style>#cff .cff-post-text a{ color: #'.$cff_posttext_link_color.'; }</style>';
1207
1208 if ( isset( $_GET['sb_debug'] ) ) {
1209 $cff_content .= $this->sb_get_debug_report( $feed_options );
1210 }
1211
1212 //Return our feed HTML to display
1213 return $cff_content;
1214 }
1215
1216 /**
1217 * Get Debug Report for Feed
1218 *
1219 * @since 4.0
1220 *
1221 * @param array $feed_opitons
1222 *
1223 * @return string $output
1224 */
1225 public function sb_get_debug_report( $feed_options ) {
1226 if ( !isset( $_GET['sb_debug'] ) ) {
1227 return;
1228 }
1229 $cff_options = get_option( 'cff_style_settings' );
1230
1231 $output = '';
1232 $output .= '<p>Settings</p>';
1233 $output .= '<ul style="word-break: break-all;">';
1234
1235 $output .= '<li>Optimize Images: ';
1236 $output .= isset( $cff_options[ 'cff_disable_resize' ] ) && $cff_options[ 'cff_disable_resize' ] == 'on' ? 'Enabled' : 'Disabled';
1237 $output .= "</li>";
1238 $output .= "</li>";
1239 $output .= '<li>AJAX theme loading fix: ';
1240 $output .= isset( $cff_options[ 'cff_disable_ajax_cache' ] ) && $cff_options[ 'cff_disable_ajax_cache' ] == true ? 'Enabled' : 'Disabled';
1241 $output .= "</li>";
1242 $output .= '<li>Show Credit Link: ';
1243 $output .= isset( $cff_options['cff_format_issue'] ) && $cff_options['cff_format_issue'] == true ? 'Enabled' : 'Disabled';
1244 $output .= "</li>";
1245 $output .= '<li>Fix Text Shortening Issue: ';
1246 $output .= isset( $cff_options['cff_show_credit'] ) && $cff_options['cff_show_credit'] == true ? 'Enabled' : 'Disabled';
1247 $output .= "</li>";
1248 $output .= '<li>Admin Error Notice: ';
1249 $output .= isset( $cff_options['disable_admin_notice'] ) && $cff_options['disable_admin_notice'] == true ? 'Enabled' : 'Disabled';
1250 $output .= "</li>";
1251 $output .= '</ul>';
1252
1253 $output .= '<p>Feed Options</p>';
1254 $public_settings_keys = CFF_Shortcode::get_public_db_settings_keys();
1255
1256 $output .= '<ul style="word-break: break-all;">';
1257 foreach( $feed_options as $key => $option ) {
1258 if ( is_array( $option ) ) continue;
1259 if ( in_array( $key, $public_settings_keys, true ) ) {
1260 $output .= sprintf('<li>%s: %s</li>', esc_html( $key ), esc_html( $option ) );
1261 }
1262 }
1263 $output .= '</ul>';
1264
1265 return $output;
1266 }
1267
1268 /**
1269 * The plugin will output settings on the frontend for debugging purposes.
1270 * Safe settings to display are added here.
1271 **
1272 * @return array
1273 *
1274 * @since 4.0
1275 */
1276 public static function get_public_db_settings_keys() {
1277 $public = array(
1278 'ownaccesstoken',
1279 'id',
1280 'pagetype',
1281 'num',
1282 'limit',
1283 'others',
1284 'showpostsby',
1285 'cachetype',
1286 'cachetime',
1287 'cacheunit',
1288 'locale',
1289 'storytags',
1290 'ajax',
1291 'offset',
1292 'account',
1293 'width',
1294 'widthresp',
1295 'height',
1296 'padding',
1297 'bgcolor',
1298 'showauthor',
1299 'showauthornew',
1300 'class',
1301 'type',
1302 'gdpr',
1303 'loadiframes',
1304 'eventsource',
1305 'eventoffset',
1306 'eventimage',
1307 'pastevents',
1308 'albumsource',
1309 'showalbumtitle',
1310 'showalbumnum',
1311 'albumcols',
1312 'photosource',
1313 'photocols',
1314 'videosource',
1315 'showvideoname',
1316 'showvideodesc',
1317 'videocols',
1318 'playlist',
1319 'disablelightbox',
1320 'filter',
1321 'exfilter',
1322 'layout',
1323 'enablenarrow',
1324 'oneimage',
1325 'mediaposition' => 'above',
1326 'include',
1327 'exclude',
1328 'masonry',
1329 'masonrycols',
1330 'masonrycolsmobile',
1331 'masonryjs',
1332 'cols',
1333 'colsmobile',
1334 'colsjs',
1335 'nummobile',
1336 'poststyle',
1337 'postbgcolor',
1338 'postcorners',
1339 'boxshadow',
1340 'textformat',
1341 'textsize',
1342 'textweight',
1343 'textcolor',
1344 'textlinkcolor',
1345 'textlink',
1346 'posttags',
1347 'linkhashtags',
1348 'lightboxcomments',
1349 'authorsize',
1350 'authorcolor',
1351 'descsize',
1352 'descweight',
1353 'desccolor',
1354 'linktitleformat',
1355 'linktitlesize',
1356 'linkdescsize',
1357 'linkurlsize',
1358 'linkdesccolor',
1359 'linktitlecolor',
1360 'linkurlcolor',
1361 'linkbgcolor',
1362 'linkbordercolor',
1363 'disablelinkbox',
1364 'eventtitleformat',
1365 'eventtitlesize',
1366 'eventtitleweight',
1367 'eventtitlecolor',
1368 'eventtitlelink',
1369 'eventdatesize',
1370 'eventdateweight',
1371 'eventdatecolor',
1372 'eventdatepos',
1373 'eventdateformat',
1374 'eventdatecustom',
1375 'timezoneoffset',
1376 'cff_enqueue_with_shortcode',
1377 'eventdetailssize',
1378 'eventdetailsweight',
1379 'eventdetailscolor',
1380 'eventlinkcolor',
1381 'datepos',
1382 'datesize',
1383 'dateweight',
1384 'datecolor',
1385 'dateformat',
1386 'datecustom',
1387 'timezone',
1388 'beforedate',
1389 'afterdate',
1390 'linksize',
1391 'linkweight',
1392 'linkcolor',
1393 'viewlinktext',
1394 'linktotimeline',
1395 'buttoncolor',
1396 'buttonhovercolor',
1397 'buttontextcolor',
1398 'buttontext',
1399 'nomoretext',
1400 'iconstyle',
1401 'socialtextcolor',
1402 'socialbgcolor',
1403 'sociallinkcolor',
1404 'expandcomments',
1405 'commentsnum',
1406 'hidecommentimages',
1407 'loadcommentsjs',
1408 'salesposts',
1409 'textlength',
1410 'desclength',
1411 'showlikebox',
1412 'likeboxpos',
1413 'likeboxoutside',
1414 'likeboxcolor',
1415 'likeboxtextcolor',
1416 'likeboxwidth',
1417 'likeboxfaces',
1418 'likeboxborder',
1419 'likeboxcover',
1420 'likeboxsmallheader',
1421 'likeboxhidebtn',
1422 'credit',
1423 'textissue',
1424 'disablesvgs',
1425 'restrictedpage',
1426 'hidesupporterposts',
1427 'privategroup',
1428 'nofollow',
1429 'timelinepag',
1430 'gridpag',
1431 'disableresize',
1432 'showheader',
1433 'headertype',
1434 'headercover',
1435 'headeravatar',
1436 'headername',
1437 'headerbio',
1438 'headercoverheight',
1439 'headerlikes',
1440 'headeroutside',
1441 'headertext',
1442 'headerbg',
1443 'headerpadding',
1444 'headertextsize',
1445 'headertextweight',
1446 'headertextcolor',
1447 'headericon',
1448 'headericoncolor',
1449 'headericonsize',
1450 'headerinc',
1451 'headerexclude',
1452 'loadmore',
1453 'fulllinkimages',
1454 'linkimagesize',
1455 'postimagesize',
1456 'videoheight',
1457 'videoaction',
1458 'videoplayer',
1459 'sepcolor',
1460 'sepsize',
1461 'seemoretext',
1462 'seelesstext',
1463 'photostext',
1464 'facebooklinktext',
1465 'sharelinktext',
1466 'showfacebooklink',
1467 'showsharelink',
1468 'buyticketstext',
1469 'maptext',
1470 'interestedtext',
1471 'goingtext',
1472 'previouscommentstext',
1473 'commentonfacebooktext',
1474 'likesthistext',
1475 'likethistext',
1476 'reactedtothistext',
1477 'andtext',
1478 'othertext',
1479 'otherstext',
1480 'noeventstext',
1481 'replytext',
1482 'repliestext',
1483 'learnmoretext',
1484 'shopnowtext',
1485 'messagepage',
1486 'getdirections',
1487 'secondtext',
1488 'secondstext',
1489 'minutetext',
1490 'minutestext',
1491 'hourtext',
1492 'hourstext',
1493 'daytext',
1494 'daystext',
1495 'weektext',
1496 'weekstext',
1497 'monthtext',
1498 'monthstext',
1499 'yeartext',
1500 'yearstext',
1501 'agotext',
1502 'multifeedactive',
1503 'daterangeactive',
1504 'featuredpostactive',
1505 'albumactive',
1506 'masonryactive',
1507 'carouselactive',
1508 'reviewsactive',
1509 'from',
1510 'until',
1511 'featuredpost',
1512 'album',
1513 'daterange',
1514 'lightbox',
1515 'reviewsrated',
1516 'starsize',
1517 'hidenegative',
1518 'reviewslinktext',
1519 'reviewshidenotext',
1520 'reviewsmethod',
1521 'feedtype',
1522 'likeboxcustomwidth',
1523 'colstablet',
1524 'feedlayout',
1525 'colorpalette',
1526 'custombgcolor1',
1527 'custombgcolor2',
1528 'textcolor1',
1529 'textcolor2',
1530 'posttextcolor',
1531 'misctextcolor',
1532 'misclinkcolor',
1533 'headericonenabled',
1534 'lightboxbgcolor',
1535 'lightboxtextcolor',
1536 'lightboxlinkcolor',
1537 'beforedateenabled',
1538 'afterdateenabled',
1539 'showpoststypes',
1540 'headerbiosize',
1541 'headerbiocolor',
1542 'apipostlimit',
1543 'carouselheight',
1544 'carouseldesktop_cols',
1545 'carouselmobile_cols',
1546 'carouselnavigation',
1547 'carouselpagination',
1548 'carouselautoplay',
1549 'carouselinterval',
1550 );
1551
1552 return $public;
1553 }
1554
1555 /* NEW 3.0 Methods */
1556 /**
1557 * Whether or not this feed is meant to use the new settings
1558 * or legacy settings
1559 *
1560 * @param array $feed_options
1561 *
1562 * @return bool
1563 *
1564 * @since 4.0
1565 */
1566 public function using_legacy_feed( $feed_options ) {
1567 $cff_statuses = get_option( 'cff_statuses', array() );
1568
1569 if ( isset( $cff_statuses['support_legacy_shortcode'] )
1570 && is_array( $cff_statuses['support_legacy_shortcode'] )) {
1571 return empty( $feed_options['feed'] );
1572 }
1573
1574 if ( empty( $cff_statuses['support_legacy_shortcode'] ) ) {
1575 return false;
1576 }
1577
1578 return empty( $feed_options['feed'] );
1579 }
1580
1581 /**
1582 * If a single unique feed was detected when updating from version 3.x
1583 * to version 4.0, a shortcode without a feed specified will be defaulted
1584 * to feed=1
1585 *
1586 * @param $feed_options
1587 *
1588 * @return bool
1589 */
1590 public function is_legacy_feed_one( $feed_options ) {
1591 $cff_statuses = get_option( 'cff_statuses', array() );
1592
1593 if ( isset( $cff_statuses['support_legacy_shortcode'] )
1594 && is_array( $cff_statuses['support_legacy_shortcode'] )) {
1595 return empty( $feed_options['feed'] );
1596 }
1597
1598 return false;
1599 }
1600
1601 /**
1602 * For non-legacy feeds. Queries the new db tables to see if the feed
1603 * exists and then converts the settings to what is usable by the plugin.
1604 *
1605 * @param array $feed_options
1606 *
1607 * @return array|bool
1608 *
1609 * @since 4.0
1610 */
1611 function get_settings_for_feed( $feed_options ) {
1612 if ( ! is_array( $feed_options ) ) {
1613 $feed_options = array();
1614 }
1615
1616 if ( $this->is_legacy_feed_one( $feed_options ) ) {
1617 $feed_options['feed'] = 1;
1618 }
1619
1620 if ( ! $this->using_legacy_feed( $feed_options ) ) {
1621
1622 $feed_id = isset( $feed_options['feed'] ) ? $feed_options['feed'] : false;
1623
1624 if ( empty( $feed_id ) ) {
1625 $feed_list = \CustomFacebookFeed\Builder\CFF_Feed_Builder::get_feed_list();
1626
1627 if ( count( $feed_list ) === 1 ) {
1628 $feed_saver = new \CustomFacebookFeed\Builder\CFF_Feed_Saver( $feed_list[0]['id'] );
1629 $settings = $feed_saver->get_feed_settings();
1630 } else {
1631 if (( current_user_can('editor') || current_user_can('administrator') ) ) {
1632 echo "<span id='cff-no-id'>" . sprintf( __( "It looks like you have more than one feed. Go to %sthis page%s and enter the intended feed ID in your shortcode like this: [custom-facebook-feed feed=YOUR_FEED_ID_HERE].", 'custom-facebook-feed' ), '<a href="' . esc_url( admin_url( 'admin.php?page=cff-feed-builder' ) ) . '">', '</a>' ) . "</span><br /><br />";
1633 }
1634 return false;
1635 }
1636
1637 } else {
1638 $feed_saver = new \CustomFacebookFeed\Builder\CFF_Feed_Saver( $feed_id );
1639 $settings = $feed_saver->get_feed_settings();
1640 }
1641
1642 if ( empty( $settings ) ) {
1643 if (( current_user_can('editor') || current_user_can('administrator') ) ) {
1644 $feed_list = \CustomFacebookFeed\Builder\CFF_Feed_Builder::get_feed_list();
1645 if ( empty( $feed_list ) ) {
1646 echo "<span id='cff-no-id'>" . sprintf( __( "It looks like you haven't set up a feed yet. Try going to %sthis page%s to create one and then enter the feed id in the shortcode like this [custom-facebook-feed feed=YOUR_FEED_ID_HERE].", 'custom-facebook-feed' ), '<a href="' . esc_url( admin_url( 'admin.php?page=cff-feed-builder' ) ) . '">', '</a>' ) . "</span><br /><br />";
1647 }
1648 }
1649 return false;
1650 } elseif ( empty( $settings['sources'] ) ) {
1651 if (( current_user_can('editor') || current_user_can('administrator') ) ) {
1652 echo "<span id='cff-no-id'>" . sprintf( __( "No source found for this feed. It looks like you may have removed the account this feed was using to display posts. Go to %sthis page%s, switch to the settings tab and click the sources menu item to manage sources for this feed.", 'custom-facebook-feed' ), '<a href="' . esc_url( admin_url( 'admin.php?page=cff-feed-builder&feed_id=' . (int) $feed_id ) ) . '">', '</a>' ) . "</span><br /><br />";
1653 }
1654 return $settings;
1655 }
1656
1657
1658 if ( empty( $settings['showpoststypes'] )
1659 || $settings['showpoststypes'] === 'all' ) {
1660 $settings['type'] = 'links,events,videos,photos,albums,statuses';
1661 }
1662
1663 if ( ! empty( $settings['feedtype'] ) && $settings['feedtype'] !== 'timeline' ) {
1664 $settings['type'] = $settings['feedtype'];
1665 }
1666
1667
1668 } else {
1669 $settings = CFF_FB_Settings::get_legacy_settings( $feed_options );
1670
1671 if ( ! empty( $feed_options['type'] ) ) {
1672 $settings['feedtype'] = $feed_options['type'];
1673 $settings['type'] = $feed_options['type'];
1674
1675 } else {
1676 if ( empty( $settings['showpoststypes'] )
1677 || $settings['showpoststypes'] === 'all' ) {
1678 $settings['type'] = 'links,events,videos,photos,albums,statuses';
1679 }
1680
1681 if ( ! empty( $settings['feedtype'] ) && $settings['feedtype'] !== 'timeline' ) {
1682 $settings['type'] = $settings['feedtype'];
1683 }
1684 }
1685
1686 $default_grid = [
1687 'albums',
1688 'videos',
1689 'photos',
1690 'singlealbum'
1691 ];
1692
1693 $type_setting_array = is_array( $settings['type'] ) ? array_filter( $settings['type'] ) : array_filter( explode( ',', $settings['type'] ) );
1694
1695 $single_type = count( $type_setting_array ) === 1 ? $type_setting_array[0] : false;
1696
1697 if ( ! empty( $feed_options['album'] ) ) {
1698 $single_type = 'singlealbum';
1699 }
1700
1701 if ( $single_type ) {
1702 if ( in_array( $single_type, $default_grid ) ) {
1703 if ( empty( $feed_options['feedlayout'] ) ) {
1704 $settings['feedlayout'] = 'grid';
1705 }
1706 if ( empty( $feed_options['cols'] ) ) {
1707 $colskey = substr( $single_type, 0, -1 ) . 'cols';
1708 $options_val = isset( $settings[ $colskey ] ) ? $settings[ $colskey ] : 4;
1709 $settings['cols'] = isset( $settings[ $colskey ] ) ? $settings[ $colskey ] : $options_val;
1710 }
1711 }
1712 $settings['feedtype'] = $single_type;
1713 }
1714
1715 }
1716
1717 $cff_includes = $settings['include'];
1718 $cff_excludes = $settings['exclude'];
1719
1720 $cff_show_like_box = false;
1721 if ( is_string( $cff_includes ) ) {
1722 if ( CFF_Utils::stripos($cff_includes, 'likebox') !== false ) $cff_show_like_box = true;
1723 } elseif ( in_array( 'likebox', $cff_includes ) ) {
1724 $cff_show_like_box = true;
1725 }
1726 if ( is_string( $cff_excludes ) ) {
1727 if ( CFF_Utils::stripos($cff_excludes, 'likebox') !== false ) $cff_show_like_box = false;
1728 } elseif ( in_array( 'likebox', $cff_excludes ) ) {
1729 $cff_show_like_box = false;
1730 }
1731
1732 if ( ! isset( $feed_options['include'] ) && ! isset( $feed_options['exclude'] ) ) {
1733 if ( ! empty( $settings['showlikebox'] ) ) {
1734 $settings['showlikebox'] = $settings['showlikebox'] === false || $settings['showlikebox'] === 'off' ? false : true;
1735 } else {
1736 $settings['showlikebox'] = $cff_show_like_box;
1737 }
1738 } else {
1739 $settings['showlikebox'] = $cff_show_like_box;
1740 }
1741
1742 if ( ! $settings['showlikebox'] ) {
1743 $settings['include'] = str_replace( 'likebox,', ',', $settings['include'] );
1744 }
1745
1746 if ( ! empty( $settings['headericonenabled'] ) && $settings['headericonenabled'] === 'off' ) {
1747 $settings['headericon'] = '';
1748 }
1749
1750 if ( ! empty( $settings['apipostlimit'] )
1751 && $settings['apipostlimit'] === 'auto') {
1752 $settings['limit'] = '';
1753 }
1754
1755 if ( $settings['poststyle'] === 'regular' ) {
1756 $settings['boxshadow'] = false;
1757 }
1758
1759 if ( isset( $feed_options['ajax'] ) ) {
1760 $settings['ajax'] = $feed_options['ajax'];
1761 } else {
1762 $settings['ajax'] = get_option( 'cff_ajax', '' );
1763 }
1764 $settings['locale'] = ( isset( $feed_options['locale'] ) ) ? $feed_options['locale'] : get_option( 'cff_locale', 'en_US' );
1765
1766 // Default Timezone
1767 $defaults = array(
1768 'cff_timezone' => 'America/Chicago',
1769 'gdpr' => 'auto',
1770 'cff_show_credit' => false,
1771 'cff_format_issue' => '',
1772 'disable_admin_notice' => false
1773 );
1774 $style_options = get_option( 'cff_style_settings', $defaults );
1775 $settings['timezone'] = (isset($style_options[ 'cff_timezone' ])) ? $style_options[ 'cff_timezone' ] : $defaults[ 'cff_timezone' ];
1776 $settings['gdpr'] = (isset($style_options[ 'gdpr' ])) ? $style_options[ 'gdpr' ] : $defaults[ 'gdpr' ];
1777 $settings['credit'] = (isset($style_options[ 'cff_show_credit' ])) ? $style_options[ 'cff_show_credit' ] : $defaults[ 'cff_show_credit' ];
1778 $settings['textissue'] = (isset($style_options[ 'cff_format_issue' ])) ? $style_options[ 'cff_format_issue' ] : $defaults[ 'cff_format_issue' ];
1779 $settings['likeboxheight'] = '';
1780 $settings['disablestyles'] = isset($style_options[ 'cff_disable_styles' ]) ? $style_options[ 'cff_disable_styles' ] : '';
1781
1782 $settings['cachetime'] = isset($feed_options[ 'cachetime' ]) ? $feed_options[ 'cachetime' ] : get_option( 'cff_cache_time', '1' );
1783 $settings['cacheunit'] = isset($feed_options[ 'cacheunit' ]) ? $feed_options[ 'cacheunit' ] : get_option( 'cff_cache_time_unit', 'hours' );
1784
1785 $maybe_legacy_shortcode = $feed_options;
1786 if ( isset( $maybe_legacy_shortcode['feed'] ) ) {
1787 unset( $maybe_legacy_shortcode['feed'] );
1788 }
1789
1790 // Merge in legacy settings (shortcode only settings)
1791 if ( ! empty( $maybe_legacy_shortcode ) ) {
1792 $legacy_shortcode_settings = [
1793 'width',
1794 'widthresp',
1795 'mediaposition',
1796 'masonryjs',
1797 'colsjs',
1798 'textformat',
1799 //all text weight settings
1800 'textweight',
1801 'descweight',
1802 'eventtitleweight',
1803 'eventdateweight',
1804 'eventdetailsweight',
1805 'dateweight',
1806 'linkweight',
1807 'headertextweight',
1808 'posttags',
1809 'linkhashtags',
1810 'offset',
1811 'cff_enqueue_with_shortcode',
1812 'commentsnum',
1813 'restrictedpage',
1814 'hidesupporterposts',
1815 'privategroup',
1816 'fulllinkimages',
1817 'linkimagesize',
1818 'postimagesize',
1819 'videoheight',
1820 'videoaction',
1821 'videoplayer',
1822 'class',
1823 'padding'
1824 ];
1825
1826 foreach ( $maybe_legacy_shortcode as $maybe_legacy => $value ) {
1827 if ( in_array( $maybe_legacy, $legacy_shortcode_settings, true ) ) {
1828 $settings[ $maybe_legacy ] = $value;
1829 }
1830 }
1831
1832 if ( $settings['posttags'] === 'false' ) {
1833 $settings['posttags'] = false;
1834 }
1835
1836 if ( $settings['linkhashtags'] === 'false' ) {
1837 $settings['linkhashtags'] = false;
1838 }
1839 }
1840
1841 if ( ! CFF_Utils::cff_is_pro_version() ) {
1842 $this->page_id = $settings['id'];
1843 $encryption = new SB_Facebook_Data_Encryption();
1844 $this->access_token = $encryption->decrypt($settings['accesstoken']) ? $encryption->decrypt($settings['accesstoken']) : $settings['accesstoken'];
1845 $this->feed_id = ! empty( $feed_id ) ? $feed_id : 'default';
1846 }
1847
1848 return \CustomFacebookFeed\Builder\CFF_Post_Set::builder_to_general_settings_convert( $settings );
1849 }
1850
1851 /**********
1852 * Ported from Pro version, could use cleanup
1853 *
1854 * TODO: Remove all or part of functions not needed for free
1855 *************/
1856
1857 /**
1858 * this where you could take the feed options to get the feed data for the first set
1859 * of posts or, if the $before and $after parameters are set, get the next set of posts
1860 *
1861 * @since 3.18
1862 */
1863 static function cff_get_json_data( $feed_options, $next_urls_arr_safe, $data_att_html, $is_customizer = false ) {
1864 //Define vars
1865 $access_token = $feed_options['accesstoken'];
1866 //If the 'Enter my own Access Token' box is unchecked then don't use the user's access token, even if there's one in the field
1867 $feed_options['ownaccesstoken'] ? $cff_show_access_token = true : $cff_show_access_token = true;
1868 //Reviews Access Token
1869 $page_access_token = $feed_options['pagetoken'];
1870 $cff_show_access_token = true;
1871 $page_id = trim( $feed_options['id'] );
1872 $show_posts = isset( $feed_options['minnum'] ) ? $feed_options['minnum'] : $feed_options['num'];
1873 $show_posts_number = isset( $feed_options['minnum'] ) ? $feed_options['minnum'] : $feed_options['num'];
1874
1875 $cff_post_limit = $feed_options['limit'];
1876 $cff_page_type = $feed_options[ 'pagetype' ];
1877 $show_others = $feed_options['others'];
1878 $show_posts_by = $feed_options['showpostsby'];
1879 $cff_caching_type = $feed_options['cachetype'];
1880 $cff_cache_time = $feed_options['cachetime'];
1881 $cff_cache_time_unit = $feed_options['cacheunit'];
1882 $cff_locale = $feed_options['locale'];
1883 //Post types
1884 $cff_types = $feed_options['type'];
1885 $cff_events_source = $feed_options[ 'eventsource' ];
1886 $cff_event_offset = $feed_options[ 'eventoffset' ];
1887 $cff_albums_source = $feed_options[ 'albumsource' ];
1888 $cff_photos_source = $feed_options[ 'photosource' ];
1889 $cff_videos_source = $feed_options[ 'videosource' ];
1890 //Past events
1891 $cff_past_events = $feed_options['pastevents'];
1892 //Active extensions
1893 $cff_ext_multifeed_active = $feed_options[ 'multifeedactive' ];
1894 #$cff_ext_date_active = $feed_options[ 'daterangeactive' ];
1895 $cff_ext_date_active = CFF_FB_Settings::check_active_extension( 'date_range' ) && CFF_Utils::check_if_on($feed_options['daterange']);
1896
1897 $cff_featured_post_active = $feed_options[ 'featuredpostactive' ];
1898 $cff_album_active = $feed_options[ 'albumactive' ];
1899 $cff_masonry_columns_active = false; //Deprecated
1900 $cff_carousel_active = $feed_options[ 'carouselactive' ];
1901 $cff_reviews_active = $feed_options[ 'reviewsactive' ];
1902 //Extension settings
1903 $cff_album_id = $feed_options['album'];
1904 $cff_featured_post_id = $feed_options['featuredpost'];
1905 $include_extras = isset( $feed_options['include_extras'] );
1906
1907 //Get show posts attribute. If not set then default to 25
1908 if (empty($show_posts)) $show_posts = 25;
1909 if ( $show_posts == 0 || $show_posts == 'undefined' ) $show_posts = 25;
1910
1911 //Set the page type
1912 $cff_is_group = false;
1913 if ($cff_page_type == 'group') $cff_is_group = true;
1914
1915 //Look for non-plural version of string in the types string in case user specifies singular in shortcode
1916 $cff_show_links_type = true;
1917 $cff_show_event_type = true;
1918 $cff_show_video_type = true;
1919 $cff_show_photos_type = true;
1920 $cff_show_status_type = true;
1921 $cff_show_albums_type = true;
1922
1923 $cff_events_only = false;
1924 $cff_albums_only = false;
1925 $cff_photos_only = false;
1926 $cff_videos_only = false;
1927
1928 //Is it SSL?
1929 $cff_ssl = '';
1930 if (is_ssl()) $cff_ssl = '&return_ssl_resources=true';
1931
1932 //Use posts? or feed?
1933 $graph_query = 'posts';
1934 $cff_show_only_others = false;
1935
1936 //If 'others' shortcode option is used then it overrides any other option
1937 if ($show_others) {
1938 //Show posts by everyone
1939 if ( $show_others == 'on' || $show_others == 'true' || $show_others == true || $cff_is_group ) $graph_query = 'feed';
1940 //Only show posts by me
1941 if ( $show_others == 'false' ) $graph_query = 'posts';
1942 } else {
1943 //Else use the settings page option or the 'showpostsby' shortcode option
1944 //Only show posts by me
1945 if ( $show_posts_by == 'me' ) $graph_query = 'posts';
1946 //Show posts by everyone
1947 if ( $show_posts_by == 'others' || $cff_is_group ) $graph_query = 'feed';
1948 //Show posts ONLY by others
1949 if ( $show_posts_by == 'onlyothers' && !$cff_is_group ) {
1950 $graph_query = 'visitor_posts';
1951 $cff_show_only_others = true;
1952 }
1953 }
1954
1955
1956 //Calculate the cache time in seconds
1957 if($cff_cache_time_unit == 'minutes') $cff_cache_time_unit = 60;
1958 if($cff_cache_time_unit == 'hour' || $cff_cache_time_unit == 'hours') $cff_cache_time_unit = 60*60;
1959 if($cff_cache_time_unit == 'days') $cff_cache_time_unit = 60*60*24;
1960 if ( intval( $cff_cache_time ) < 1 ) {
1961 $cff_cache_time = 1;
1962 }
1963 $cache_seconds = intval( $cff_cache_time ) * intval( $cff_cache_time_unit );
1964
1965
1966 //********************************************//
1967 //*****************GET POSTS******************//
1968 //********************************************//
1969 $FBdata_arr = array(); //Use an array to store the data for each page ID (for multifeed)
1970 $page_ids = array($page_id);
1971
1972
1973 //If the limit isn't set then set it to be 7 more than the number of posts defined
1974 if ( isset($cff_post_limit) && $cff_post_limit !== '' ) {
1975 $cff_post_limit = $cff_post_limit;
1976 } else {
1977 if( intval($show_posts) >= 50 ) $cff_post_limit = intval(intval($show_posts) + 7);
1978 if( intval($show_posts) < 50 ) $cff_post_limit = intval(intval($show_posts) + 5);
1979 if( intval($show_posts) < 25 ) $cff_post_limit = intval(intval($show_posts) + 4);
1980 if( intval($show_posts) < 10 ) $cff_post_limit = intval(intval($show_posts) + 3);
1981 if( intval($show_posts) < 6 ) $cff_post_limit = intval(intval($show_posts) + 2);
1982 if( intval($show_posts) < 2 ) $cff_post_limit = intval(intval($show_posts) + 1);
1983
1984 //If using multifeed then set the limit dynamically based on the number of pages if it isn't set
1985 if( $cff_ext_multifeed_active && count($page_ids) > 1 ){
1986 $cff_post_limit = ( ceil(intval($show_posts) / count($page_ids)) ) + 1;
1987 }
1988 }
1989 if( $cff_post_limit >= 100 ) $cff_post_limit = 100;
1990
1991 //If the number of posts is set to zero then don't show any and set limit to one
1992 if ( ($show_posts == '0' || $show_posts == 0) && $show_posts !== ''){
1993 $show_posts = 0;
1994 $cff_post_limit = 1;
1995 }
1996
1997 //If the timeline pagination method is set to use the API paging method then set the limit to be the number of posts displayed so that posts aren't skipped when loading more
1998 if( $feed_options['timelinepag'] == 'paging' ) $cff_post_limit = $show_posts;
1999
2000
2001 //Loop through page IDs
2002 foreach ( $page_ids as $page_id ) {
2003
2004 //********************************************//
2005 //********CREATE THE API REQUEST URL**********//
2006 //********************************************//
2007
2008 //ALL POSTS
2009
2010 //Add option to remove attachments description field to workaround Facebook "Unsupported Get Request" bug caused by sales posts in the API request
2011 $attachments_desc = ( $feed_options['salesposts'] == 'true' ) ? '' : ',description';
2012
2013 //Add option to remove story_tags to workaround Facebook "Unknown Error" message returned by API for certain posts
2014 $story_tags = ( $feed_options['storytags'] == 'true' ) ? '' : ',story_tags';
2015 $cff_posts_json_url = 'https://graph.facebook.com/v4.0/' . $page_id . '/' . $graph_query . '?fields=id,updated_time,from{picture,id,name,link},message,message_tags,story'. $story_tags .',picture,full_picture,status_type,created_time,backdated_time,attachments{title'. $attachments_desc .',media_type,unshimmed_url,target{id},multi_share_end_card,media{source,image},subattachments},shares,call_to_action,privacy&access_token=' . $access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale . $cff_ssl;
2016
2017
2018 //********************************************//
2019 //*********CREATE THE TRANSIENT NAME**********//
2020 //********************************************//
2021
2022
2023
2024 //ALL POSTS
2025 if (!$cff_events_only || ($cff_events_only && $cff_events_source == 'timeline') ){
2026
2027 //If it's a playlist then use the playlist ID instead of the Page ID
2028 $page_id_caching = $page_id;
2029 if( $feed_options['playlist'] ){
2030 $page_id_caching = $feed_options['playlist'];
2031 }
2032
2033 $trans_items_arr = array(
2034 'page_id' => $page_id_caching,
2035 'post_limit' => substr($cff_post_limit, 0, 3),
2036 'show_posts_by' => substr($show_posts_by, 0, 2),
2037 'locale' => $cff_locale
2038 );
2039
2040 $trans_arr_item_count = 1;
2041 if( $cff_featured_post_active && !empty($cff_featured_post_id) ){
2042 $trans_items_arr['featured_post'] = $cff_featured_post_id;
2043 $trans_arr_item_count++;
2044 }
2045 if($cff_albums_only) $trans_items_arr['albums_source'] = $cff_albums_source;
2046 $trans_items_arr['albums_only'] = intval($cff_albums_only);
2047 $trans_items_arr['photos_only'] = intval($cff_photos_only);
2048 $trans_items_arr['videos_only'] = intval($cff_videos_only);
2049
2050 $arr_item_max_length = floor( 28/$trans_arr_item_count ); //40 minus the 12 needed for the other 7 values shown below equals 28
2051 $arr_item_max_length_half = floor($arr_item_max_length/2);
2052
2053 $transient_name = 'cff_';
2054 foreach ($trans_items_arr as $key => $value) {
2055 if($value !== false){
2056 if( $key == 'page_id' || $key == 'featured_post' || $key == 'from' || $key == 'until' ) $transient_name .= substr($value, 0, $arr_item_max_length_half) . substr($value, $arr_item_max_length_half*-1); //-10
2057 if( $key == 'locale' ) $transient_name .= substr($value, 0, 2);
2058 if( $key == 'post_limit' || $key == 'show_posts_by' ) $transient_name .= substr($value, 0, 3);
2059 if( $key == 'albums_only' || $key == 'photos_only' || $key == 'videos_only' || $key == 'albums_source' || $key == 'reviews' ) $transient_name .= substr($value, 0, 1);
2060 }
2061 }
2062 //Make sure it's not more than 45 chars
2063 $transient_name = substr($transient_name, 0, 45);
2064
2065 //ALBUM EMBED
2066 if( $cff_album_active && !empty($cff_album_id) ) {
2067 $transient_name = 'cff_album_' . $cff_album_id . '_' . $cff_post_limit;
2068 $transient_name = substr($transient_name, 0, 45);
2069 }
2070
2071 } //END ALL POSTS
2072
2073
2074
2075 //Are there more posts to get for this ID?
2076 $cff_more_posts = true;
2077
2078 //If the cron caching is enabled then set the caching time to be long so that it doesn't expire before rechecked in the cron function
2079 if( false == 'background' ) $cache_seconds = 7 * DAY_IN_SECONDS;
2080
2081
2082 //ALL POSTS
2083 $posts_json = CFF_Utils::cff_get_set_cache($cff_posts_json_url, $transient_name, $cff_cache_time, $cache_seconds, $data_att_html, $cff_show_access_token, $access_token, true);
2084 if( $cff_is_group ){
2085 $groups_post = new CFF_Group_Posts($page_id, $feed_options, $cff_posts_json_url, $data_att_html, false);
2086 $groups_post_result = $groups_post->init_group_posts($posts_json, false, $show_posts_number);
2087 $posts_json = $groups_post_result['posts_json'];
2088 }
2089 //ALBUM EMBED
2090 if( $cff_album_active && !empty($cff_album_id) ) $album_json = $posts_json;
2091
2092 //Interpret data with JSON
2093 $FBdata = json_decode($posts_json);
2094
2095 if ( false /*$is_customizer*/ ) {
2096 //Get more data about single events since timelines don't have it
2097 $can_check_for_events = false;
2098 $event_supporting_access_tokens = array();
2099 if ( isset( $feed_options['sources'][0] ) ) {
2100 foreach ( $feed_options['sources'] as $source ) {
2101 #if ( $source['privilege'] === 'events' ) {
2102 $can_check_for_events = true;
2103 $event_supporting_access_tokens[ $source['account_id'] ] = $source['access_token'];
2104 # }
2105 }
2106 }
2107
2108
2109 if ( $can_check_for_events ) {
2110 if ( isset( $FBdata->data ) ) {
2111 $post_index = 0;
2112 foreach ( $FBdata->data as $post ) {
2113 $type = CFF_Parse::get_status_type( $post );
2114
2115 if ( $type === 'created_event' ) {
2116 $account_id = CFF_Parse::get_from_id( $post );
2117 $post_id = CFF_Parse::get_post_id( $post );
2118 $event_id = explode( '_', $post_id );
2119 $event_id = $event_id[1];
2120
2121 if ( ! empty( $event_supporting_access_tokens[ $account_id ] ) ) {
2122 $single_data = CFF_Shortcode::get_single_event_data( $event_id, $event_supporting_access_tokens[ $account_id ] );
2123 foreach( $single_data as $property => $value ) {
2124 $FBdata->data[ $post_index ]->$property = $value;
2125 }
2126
2127 }
2128 }
2129 $post_index++;
2130 }
2131 }
2132 }
2133 }
2134
2135
2136 if( $cff_more_posts ){
2137 //Add the data to the array to be returned and parsed into HTML
2138 $FBdata_arr[$page_id] = $FBdata;
2139 } else {
2140 //Add something to the array for the ID if there's no posts to prevent any PHP notices
2141 $FBdata_arr[$page_id] = 'no_more_posts';
2142 }
2143
2144 //Add the API URL to the json array so that we can grab it and add to the button if needed
2145 if( isset($FBdata_arr[$page_id]) ){
2146 if( !isset($FBdata_arr[$page_id]->api_url) && $FBdata_arr[$page_id] != 'no_more_posts' ){
2147 //Replace the actual token with the Access Token placeholder
2148 $cff_api_url = str_replace($access_token,"x_cff_hide_token_x",$cff_posts_json_url);
2149 //Add it to the json array
2150 $FBdata_arr[$page_id]->api_url = $cff_api_url;
2151 }
2152 }
2153
2154 } //End page_id loop
2155
2156 if($cff_is_group && isset($FBdata_arr[$page_id]) && $FBdata_arr[$page_id] != 'no_more_posts'){
2157 $FBdata_arr[$page_id]->is_load_cache = (isset($groups_post_result['latest_record_date'])) && $groups_post_result['latest_record_date'] !== 0 && $groups_post_result['load_from_cache'] !== false ? $groups_post_result['load_from_cache'] : false;
2158 $FBdata_arr[$page_id]->latest_record_date = $groups_post_result['latest_record_date'];
2159 }
2160 return $FBdata_arr;
2161 }
2162
2163 /**
2164 * this function breaks up the "next" url from the json data into an array of parts to load into
2165 * the html to be retrieved on click and pieced back together
2166 *
2167 * @since 3.18
2168 */
2169 static function cff_get_next_url_parts( $json_data_arr ) {
2170 $next_urls_arr_safe = '{';
2171 $next_urls_arr_safe .= '}';
2172 //If the array ends in a comma then remove the comma
2173 return $next_urls_arr_safe;
2174 }
2175
2176 public static function get_single_event_data( $eventID, $access_token ) {
2177 $encryption = new SB_Facebook_Data_Encryption();
2178
2179 //Is it SSL?
2180 $cff_ssl = '';
2181 if (is_ssl()) $cff_ssl = '&return_ssl_resources=true';
2182
2183 //Get the contents of the event
2184 $event_json_url = 'https://graph.facebook.com/v3.3/'.$eventID.'?fields=cover,place,name,owner,start_time,timezone,id,comments.summary(true){message,created_time},description&access_token=' . $access_token . $cff_ssl;
2185
2186 // Get any existing copy of our transient data
2187 $transient_name = 'cff_tle_' . $eventID;
2188 $transient_name = substr($transient_name, 0, 45);
2189
2190 if ( false === ( $event_json = $encryption->maybe_decrypt( get_transient( $transient_name ) ) ) || $event_json === null ) {
2191 //Get the contents of the Facebook page
2192 $event_json = CFF_Utils::cff_fetchUrl($event_json_url);
2193 //Cache the JSON for 180 days as the timeline event info probably isn't going to change
2194 set_transient( $transient_name, $encryption->maybe_encrypt( $event_json ) , 60 * 60 * 24 * 180 );
2195 } else {
2196 $event_json = $encryption->maybe_decrypt( get_transient( $transient_name ) );
2197 //If we can't find the transient then fall back to just getting the json from the api
2198 if ($event_json == false) $event_json = CFF_Utils::cff_fetchUrl($event_json_url);
2199 }
2200
2201 //Interpret data with JSON
2202 $event_object = json_decode($event_json);
2203
2204 $description_text = '';
2205 if( isset($event_object->name) ) $description_text .= $event_object->name . ' ';
2206 if( isset($event_object->place->location->city) ) $description_text .= $event_object->place->location->city . ' ';
2207 if( isset($event_object->place->location->country) ) $description_text .= $event_object->place->location->country . ' ';
2208 if( isset($event_object->place->location->street) ) $description_text .= $event_object->place->location->street . ' ';
2209 if( isset($event_object->place->name) ) $description_text .= $event_object->place->name . ' ';
2210 if( isset($event_object->description) ) $description_text .= $event_object->description;
2211 $event_object->description_text = $description_text;
2212
2213 return $event_object;
2214
2215 }
2216
2217 public static function add_translations( $atts ) {
2218 $translations = get_option( 'cff_style_settings', false );
2219
2220 $final_translations = [
2221 'seemoretext' => isset( $translations[ 'cff_see_more_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_see_more_text' ] ) ) : __( 'See More', 'custom-facebook-feed' ),
2222 'seelesstext' => isset( $translations[ 'cff_see_less_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_see_less_text' ] ) ) : __( 'See Less', 'custom-facebook-feed' ),
2223 'facebooklinktext' => isset( $translations[ 'cff_facebook_link_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_facebook_link_text' ] ) ) : __( 'View on Facebook', 'custom-facebook-feed' ),
2224 'sharelinktext' => isset( $translations[ 'cff_facebook_share_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_facebook_share_text' ] ) ) : __( 'Share', 'custom-facebook-feed' ),
2225
2226 'learnmoretext' => isset( $translations[ 'cff_translate_learn_more_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_learn_more_text' ] ) ) : __( 'Learn More', 'custom-facebook-feed' ),
2227 'shopnowtext' => isset( $translations[ 'cff_translate_shop_now_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_shop_now_text' ] ) ) : __( 'Shop Now', 'custom-facebook-feed' ),
2228 'messagepage' => isset( $translations[ 'cff_translate_message_page_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_message_page_text' ] ) ) : __( 'Message Page', 'custom-facebook-feed' ),
2229 'getdirections' => isset( $translations[ 'cff_translate_get_directions_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_get_directions_text' ] ) ) : __( 'Get Directions', 'custom-facebook-feed' ),
2230
2231 'secondtext' => isset( $translations[ 'cff_translate_second' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_second' ] ) ) : 'second',
2232 'secondstext' => isset( $translations[ 'cff_translate_seconds' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_seconds' ] ) ) : 'seconds',
2233 'minutetext' => isset( $translations[ 'cff_translate_minute' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_minute' ] ) ) : 'minute',
2234 'minutestext' => isset( $translations[ 'cff_translate_minutes' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_minutes' ] ) ) : 'minutes',
2235 'hourtext' => isset( $translations[ 'cff_translate_hour' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_hour' ] ) ) : 'hour',
2236 'hourstext' => isset( $translations[ 'cff_translate_hours' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_hours' ] ) ) : 'hours',
2237 'daytext' => isset( $translations[ 'cff_translate_day' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_day' ] ) ) : 'day',
2238 'daystext' => isset( $translations[ 'cff_translate_days' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_days' ] ) ) : 'days',
2239 'weektext' => isset( $translations[ 'cff_translate_week' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_week' ] ) ) : 'week',
2240 'weekstext' => isset( $translations[ 'cff_translate_weeks' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_weeks' ] ) ) : 'weeks',
2241 'monthtext' => isset( $translations[ 'cff_translate_month' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_month' ] ) ) : 'month',
2242 'monthstext' => isset( $translations[ 'cff_translate_months' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_months' ] ) ) : 'months',
2243 'yeartext' => isset( $translations[ 'cff_translate_year' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_year' ] ) ) : 'year',
2244 'yearstext' => isset( $translations[ 'cff_translate_years' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_years' ] ) ) : 'years',
2245 'agotext' => isset( $translations[ 'cff_translate_ago' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_ago' ] ) ) : 'ago',
2246
2247 'phototext' => isset( $translations[ 'cff_translate_photo_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_photo_text' ] ) ) : '',
2248 'videotext' => isset( $translations[ 'cff_translate_video_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_video_text' ] ) ) : '',
2249 ];
2250
2251
2252 $final_translations['facebooklinktext'] = ! empty( $atts['facebooklinktext'] ) ? $atts['facebooklinktext'] : $final_translations['facebooklinktext'];
2253 $final_translations['sharelinktext'] = ! empty( $atts['sharelinktext'] ) ? $atts['sharelinktext'] : $final_translations['sharelinktext'];
2254
2255 $atts = array_merge( $atts, $final_translations );
2256
2257 return $atts;
2258
2259 }
2260
2261 function cff_add_translations() {
2262 $this->atts = CFF_Shortcode::add_translations( $this->atts );
2263 }
2264
2265
2266 }
2267