PluginProbe ʕ •ᴥ•ʔ
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress / 4.1.2
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress v4.1.2
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_Display.php
custom-facebook-feed / inc Last commit date
Admin 4 years ago Builder 4 years ago Helpers 4 years ago CFF_Autolink.php 4 years ago CFF_Blocks.php 4 years ago CFF_Cache.php 4 years ago CFF_Education.php 4 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_Display.php
805 lines
1 <?php
2 /**
3 * Shortcode Display Class
4 *
5 * Contains all the functions for the diplay purposes! (Generates CSS, CSS Classes, HTML Attributes...)
6 *
7 * @since 2.19
8 */
9
10 namespace CustomFacebookFeed;
11 use CustomFacebookFeed\CFF_Utils;
12 use CustomFacebookFeed\CFF_Autolink;
13 use CustomFacebookFeed\CFF_Parse;
14
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 die( '-1' );
18 }
19
20 class CFF_Shortcode_Display {
21
22 /**
23 * Ajax Loaded
24 *
25 * Check if is Ajax Loaded then put the script inside the content
26 *
27 * @since 2.19
28 */
29 public function ajax_loaded(){
30 $ajax_loaded_content = '';
31 $ajax_theme = $this->atts['ajax'] === '1' ? 'on' : $this->atts['ajax'];
32 $ajax_theme = CFF_Utils::check_if_on( $ajax_theme );
33 if ($ajax_theme) {
34 $cff_min = isset( $this->options[ 'cff_minify' ] ) ? '.min' : '';
35 $cff_link_hashtags = CFF_Utils::check_if_on( $this->atts['textlink'] ) ? 'false' : CFF_Utils::check_if_on( $this->atts['linkhashtags'] );
36 $ajax_loaded_content .= '<script type="text/javascript">var cfflinkhashtags = "' . $cff_link_hashtags . '";</script>';
37 $ajax_loaded_content .= '<script type="text/javascript" src="' . CFF_PLUGIN_URL . 'assets/js/cff-scripts'.$cff_min.'.js?ver='.CFFVER . '"></script>';
38 }
39
40 return $ajax_loaded_content;
41 }
42
43
44 /**
45 * Style Compiler.
46 *
47 * Returns an array containing all the styles for the Feed
48 *
49 * @since 2.19
50 * @return String
51 */
52 public function style_compiler( $style_array ){
53 $style = '';
54 foreach ($style_array as $single_style) {
55 if( !empty($single_style['value']) && $single_style['value'] != '#' && $single_style['value'] != 'inherit' && $single_style['value'] !== '0' ){
56 $style .= $single_style['css_name'] . ':' .
57 (isset($single_style['pref']) ? $single_style['pref'] : '') .
58 $single_style['value'] .
59 (isset($single_style['suff']) ? $single_style['suff'] : '') .
60 ';';
61 }
62 }
63 $style = ( !empty($style) ) ? ' style="' . $style . '" ' : '';
64 return $style;
65 }
66
67 /**
68 * CSS Class Compiler .
69 *
70 * Returns custom CSS classes for the CFF list container shortcode
71 *
72 * @since 2.19
73 * @return Array
74 */
75 public function feed_style_class_compiler(){
76 $result = [
77 'cff_custom_class' => '',
78 'cff_feed_styles' => '',
79 'cff_feed_attributes' => ''
80 ];
81 //Set to be 100% width on mobile?
82 $cff_feed_width_resp = CFF_Utils::check_if_on( $this->atts['widthresp'] );
83 $cff_feed_height = CFF_Utils::get_css_distance( $this->atts[ 'height' ] ) ;
84
85 //Disable default CSS styles?
86 $cff_disable_styles = CFF_Utils::get_css_distance( $this->atts[ 'disablestyles' ] ) ;
87
88 $cff_class = $this->atts['class'];
89 //Masonry
90 $cff_cols = $this->atts['cols'];
91 $colstablet = (int)$this->atts['colstablet'];
92 $cff_cols_mobile = $this->atts['colsmobile'];
93 $cff_cols_js = $this->atts['colsjs'];
94
95 $masonry = ( intval($cff_cols) > 1 ) ? true : false;
96 $js_only = isset( $cff_cols_js ) ? $cff_cols_js : false;
97 if( $js_only === 'false' ) $js_only = false;
98
99 if( $masonry || $masonry == 'true' ){
100 //$this->atts['headeroutside'] = true;
101 }
102 $masonry_classes = '';
103 if( isset($masonry) ) {
104 if( $masonry === 'on' || $masonry === true || $masonry === 'true' ) {
105 $masonry_classes .= 'cff-masonry';
106 $masonry_classes .= ( $cff_cols != 3 ) ? sprintf( ' masonry-%s-desktop', $cff_cols ) : '';
107 $masonry_classes .= ( $cff_cols_mobile == 2 ) ? ' masonry-2-mobile' : '';
108 if( $cff_cols != 3 ) {
109 $masonry_classes .= sprintf( ' masonry-%s-desktop', $cff_cols );
110 }
111 if( $cff_cols_mobile > 1 ) {
112 $masonry_classes .= sprintf( ' masonry-%s-mobile', $cff_cols_mobile );
113 }
114 if( $colstablet > 1 ) {
115 $masonry_classes .= sprintf( ' masonry-%s-tablet', $colstablet );
116 }
117 $masonry_classes .= ( ! $js_only ) ? ' cff-masonry-css' : ' cff-masonry-js';
118 }
119 }
120
121 $mobile_cols_class = '';
122 if (! empty( $this->atts['colsmobile'] ) && (int)$this->atts['colsmobile'] > 0) {
123 $mobile_cols_class = ' cff-mob-cols-' . (int)$this->atts['colsmobile'];
124 }
125
126 $tablet_cols_class = '';
127 if (! empty( $this->atts['colstablet'] )
128 && (int)$this->atts['colstablet'] > 0
129 && (int)$this->atts['colstablet'] !== 2) {
130 $tablet_cols_class = ' cff-tab-cols-' . (int)$this->atts['colstablet'];
131 }
132
133 //If there's a class then add it here
134 $css_classes_string = '';
135
136 if( !empty($cff_class) || !empty($cff_feed_height) || !$cff_disable_styles || $cff_feed_width_resp || !empty($masonry_classes) ){
137 $css_classes_string .= ( !empty($cff_class) ) ? $cff_class : '';
138 $css_classes_string .= ( !empty($masonry_classes) ) ? $masonry_classes : '';
139 $css_classes_string .= ( !empty($cff_feed_height) ) ? ' cff-fixed-height ' : '';
140 $css_classes_string .= ( $cff_feed_width_resp ) ? ' cff-width-resp ' : '';
141 $css_classes_string .= ( !$cff_disable_styles ) ? ' cff-default-styles ' : '';
142 }
143 $css_classes_string .= $mobile_cols_class . $tablet_cols_class;
144 if ( ! empty( $this->atts['paletteclass'] ) ) {
145 $css_classes_string .= ' ' . $this->atts['paletteclass'];
146 }
147
148 $css_classes_string = ( !empty($css_classes_string) ) ? ' class="cff cff-list-container '.$css_classes_string.'" ' : 'class="cff cff-list-container"';
149
150 $title_limit = !isset($title_limit) ? $this->atts['textlength'] : 9999;
151 $attributes_string = ' data-char="'.$title_limit.'" ';
152 $mobile_num = isset( $this->atts['nummobile'] ) && (int)$this->atts['nummobile'] !== (int)$this->atts['num'] ? (int)$this->atts['nummobile'] : false;
153
154 $attributes_string .= ( $mobile_num ) ? ' data-nummobile="' . $mobile_num . '" data-pag-num="' . (int)$this->atts['num'] . '" ' : '';
155 if ( CFF_GDPR_Integrations::doing_gdpr( $this->atts ) ) {
156 $attributes_string .= ' data-cff-flags="gdpr" ';
157 }
158
159
160 $result = [
161 'cff_custom_class' => $css_classes_string,
162 'cff_feed_styles' => $this->get_style_attribute( 'feed_global' ),
163 'cff_feed_attributes' => $attributes_string
164 ];
165 return $result;
166 }
167
168
169 /**
170 * Item HTML Attributes
171 *
172 * Returns the post item feed class atrribute
173 *
174 * @since 2.19
175 * @return Array
176 */
177 public function get_item_attributes($cff_post_type, $cff_album, $cff_post_bg_color_check, $cff_post_style, $cff_box_shadow, $name, $cff_post_id){
178 #extract($args);
179 $item_class = 'cff-item ';
180 if ($cff_post_type == 'link') $item_class .= 'cff-link-item ';
181 else if ($cff_post_type == 'event') $item_class .= 'cff-timeline-event ';
182 else if ($cff_post_type == 'photo') $item_class .= 'cff-photo-post ';
183 else if ($cff_post_type == 'video') $item_class .= 'cff-video-post ';
184 else if ($cff_post_type == 'swf') $item_class .= 'cff-swf-post ';
185 else if ($cff_post_type == 'offer') $item_class .= 'cff-offer-post ';
186 else $item_class .= 'cff-status-post ';
187
188 $item_class .= $cff_album ? 'cff-album ' : '';
189 $item_class .= ($cff_post_bg_color_check || $cff_post_style == "boxed") ? 'cff-box ' : '';
190 $item_class .= $cff_box_shadow ? 'cff-shadow ' : '';
191 $item_class .= isset($name) ? 'author-'. CFF_Utils::cff_to_slug($name) : '';
192
193
194 return [
195 'class' => 'class="'. $item_class .'"',
196 'id' => 'id="cff_'. $cff_post_id .'"',
197 'style' => $this->get_post_item_style()
198 ];
199 }
200
201 /**
202 * Item CLass Attributes
203 *
204 * Returns the post item feed style attribute
205 *
206 * @since 2.19
207 * @return String
208 */
209 public function get_post_item_style(){
210 $item_style = '';
211 if( $this->atts['poststyle'] == 'regular' ){
212 $item_style = ' style="border-bottom: '. CFF_Utils::return_value( $this->atts[ 'sepsize' ] , 0). 'px solid #'. str_replace('#', '', CFF_Utils::return_value( $this->atts[ 'sepcolor' ] , 'ddd')) . ';"';
213 }else if( $this->atts['poststyle'] == 'boxed' ){
214 $item_style_array = [
215 ['css_name' => 'border-radius', 'value' => $this->atts['postcorners'] , 'suff' => 'px'],
216 ['css_name' => 'background-color', 'value' => str_replace('#', '', $this->atts['postbgcolor']), 'pref' => '#']
217 ];
218 $item_style = $this->style_compiler( $item_style_array );
219 }
220 return $item_style;
221 }
222
223 /**
224 *
225 * Style Attribute
226 * Generates the Style attribute for the Feed Elements
227 *
228 * @since 2.19
229 * @return String
230 */
231 public function get_style_attribute( $element ){
232 $style_array = [];
233 switch ($element) {
234 case 'link_box':
235 $style_array = [
236 ['css_name' => 'border', 'value' => str_replace('#', '', $this->atts['linkbordercolor']), 'pref' => ' 1px solid #'],
237 ['css_name' => 'background-color', 'value' => str_replace('#', '', $this->atts['linkbgcolor']), 'pref' => '#']
238 ];
239 break;
240 case 'body_description':
241 $style_array = [
242 ['css_name' => 'font-size', 'value' => $this->atts['descsize'], 'suff' => 'px'],
243 ['css_name' => 'font-weight', 'value' => $this->atts['descweight']],
244 ['css_name' => 'color', 'value' => str_replace('#', '', $this->atts['desccolor']), 'pref' => '#']
245 ];
246 break;
247 case 'feed_global':
248 $style_array = [
249 ['css_name' => 'width', 'value' => CFF_Utils::get_css_distance( $this->atts[ 'width' ] ) ],
250 ];
251 break;
252 case 'feed_wrapper_insider':
253 $style_array = [
254 ['css_name' => 'padding', 'value' => CFF_Utils::get_css_distance( $this->atts[ 'padding' ] ) ],
255 ['css_name' => 'height', 'value' => CFF_Utils::get_css_distance( $this->atts[ 'height' ] ) ],
256 ['css_name' => 'background-color', 'value' => str_replace('#', '', $this->atts[ 'bgcolor' ] ), 'pref' => '#']
257 ];
258 break;
259 case 'header':
260 $style_array = [
261 ['css_name' => 'background-color', 'value' => str_replace('#', '', $this->atts['headerbg']), 'pref' => '#'],
262 ['css_name' => 'padding', 'value' => CFF_Utils::get_css_distance( $this->atts['headerpadding'] ) ],
263 ['css_name' => 'font-size', 'value' => $this->atts['headertextsize'], 'suff' => 'px'],
264 ['css_name' => 'font-weight', 'value' => $this->atts['headertextweight']],
265 ['css_name' => 'color', 'value' => str_replace('#', '', $this->atts['headertextcolor']), 'pref' => '#']
266 ];
267 break;
268 case 'header_visual':
269 $style_array = [
270 ['css_name' => 'color', 'value' => str_replace('#', '', $this->atts['headertextcolor']), 'pref' => '#'],
271 ['css_name' => 'font-size', 'value' => $this->atts['headertextsize'], 'suff' => 'px'],
272 ['css_name' => 'font-weight', 'value' => $this->atts['headertextweight']]
273 ];
274 break;
275
276 case 'header_icon':
277 $style_array = [
278 ['css_name' => 'color', 'value' => str_replace('#', '', $this->atts['headericoncolor']), 'pref' => '#'],
279 ['css_name' => 'font-size', 'value' => $this->atts['headericonsize'], 'suff' => 'px']
280 ];
281 break;
282
283 case 'header_bio':
284 $style_array = [
285 ['css_name' => 'color', 'value' => str_replace('#', '', $this->atts['headerbiocolor']), 'pref' => '#'],
286 ['css_name' => 'font-size', 'value' => $this->atts['headerbiosize'], 'suff' => 'px']
287 ];
288 break;
289 case 'author':
290 $style_array = [
291 ['css_name' => 'font-size', 'value' => $this->atts['authorsize'], 'suff' => 'px'],
292 ['css_name' => 'color', 'value' => str_replace('#', '', $this->atts['authorcolor']), 'pref' => '#']
293 ];
294 break;
295 case 'date':
296 $style_array = [
297 ['css_name' => 'font-size', 'value' => $this->atts['datesize'], 'suff' => 'px'],
298 ['css_name' => 'font-weight', 'value' => $this->atts['dateweight']],
299 ['css_name' => 'color', 'value' => str_replace('#', '', $this->atts['datecolor']), 'pref' => '#']
300 ];
301 break;
302
303 case 'post_link':
304 $style_array = [
305 ['css_name' => 'font-size', 'value' => $this->atts['linksize'], 'suff' => 'px'],
306 ['css_name' => 'font-weight', 'value' => $this->atts['linkweight']],
307 ['css_name' => 'color', 'value' => str_replace('#', '', $this->atts['linkcolor']), 'pref' => '#']
308 ];
309 break;
310 case 'event_title':
311 $style_array = [
312 ['css_name' => 'font-size', 'value' => $this->atts['eventtitlesize'], 'suff' => 'px'],
313 ['css_name' => 'font-weight', 'value' => $this->atts['eventtitleweight']],
314 ['css_name' => 'color', 'value' => str_replace('#', '', $this->atts['eventtitlecolor']), 'pref' => '#']
315 ];
316 break;
317 case 'post_text':
318 $style_array = [
319 ['css_name' => 'font-size', 'value' => $this->atts['textsize'], 'suff' => 'px'],
320 ['css_name' => 'font-weight', 'value' => $this->atts['textweight']],
321 ['css_name' => 'color', 'value' => str_replace('#', '', $this->atts['textcolor']), 'pref' => '#']
322 ];
323 break;
324 case 'shared_cap_link':
325 $style_array = [
326 ['css_name' => 'font-size', 'value' => $this->atts[ 'linkurlsize' ], 'suff' => 'px'],
327 ['css_name' => 'color', 'value' => str_replace('#', '', $this->atts[ 'linkurlcolor' ]), 'pref' => '#']
328 ];
329 break;
330 case 'shared_desclink':
331 $style_array = [
332 ['css_name' => 'font-size', 'value' => $this->atts[ 'linkdescsize' ], 'suff' => 'px'],
333 ['css_name' => 'color', 'value' => str_replace('#', '', $this->atts[ 'linkdesccolor' ]), 'pref' => '#']
334 ];
335 break;
336
337 }
338
339 return $this->style_compiler( $style_array );
340 }
341
342
343 /**
344 *
345 * Style Attribute
346 * Generates the Style attribute for the Feed Elements
347 *
348 * @since 2.19
349 * @return String
350 */
351 public function check_show_section( $section_name ){
352 $is_shown = ( CFF_Utils::stripos($this->atts[ 'include' ], $section_name) !== false ) ? true : false;
353 $is_shown = ( CFF_Utils::stripos($this->atts[ 'exclude' ], $section_name) !== false ) ? false : $is_shown;
354 return $is_shown;
355 }
356
357
358
359 /**
360 *
361 * Get Author Template Data
362 * Get Authors the data for the templates
363 *
364 * @since 2.19
365 * -----------------------------------------
366 */
367
368 static function get_author_name( $news ){
369 return isset($news->from->name) ? str_replace('"', "", $news->from->name) : '';
370 }
371
372 static function get_author_link_atts( $news, $target, $cff_nofollow, $cff_author_styles ){
373 return !isset($news->from->link) ? '' : ' href="https://facebook.com/' . $news->from->id . '" '.$target.$cff_nofollow.' '.$cff_author_styles;
374 }
375
376 static function get_author_link_el( $news ){
377 return !isset($news->from->link) ? 'span' : 'a';
378 }
379
380 static function get_author_post_text_story( $post_text_story, $cff_author_name ){
381 if( !empty($cff_author_name) ){
382 $cff_author_name_pos = strpos($post_text_story, $cff_author_name);
383 if ($cff_author_name_pos !== false) {
384 $post_text_story = substr_replace($post_text_story, '', $cff_author_name_pos, strlen($cff_author_name));
385 }
386 }
387 return $post_text_story;
388 }
389
390 static function get_author_pic_src_class( $news, $atts ){
391 $cff_author_src = $cff_author_img_src = isset($news->from->picture->data->url) ? $news->from->picture->data->url : '';
392 $img_class = '';
393 if ( CFF_GDPR_Integrations::doing_gdpr( $atts ) ){
394 $cff_author_img_src = CFF_PLUGIN_URL. '/assets/img/placeholder.png';
395 $img_class = ' cff-no-consent';
396 }
397 return [
398 'real_image' => $cff_author_src,
399 'image' => $cff_author_img_src,
400 'class' => $img_class
401 ];
402 }
403
404
405 /**
406 *
407 * Get Date Data
408 * Get Date the data for the templates
409 *
410 * @since 2.19
411 * -----------------------------------------
412 */
413 static function get_date( $options, $atts, $news ){
414 $cff_date_before = isset($atts[ 'beforedate' ]) && CFF_Utils::check_if_on($atts['beforedateenabled']) ? $atts[ 'beforedate' ] : '';
415 $cff_date_after = isset($atts[ 'afterdate' ]) && CFF_Utils::check_if_on($atts['afterdateenabled']) ? $atts[ 'afterdate' ] : '';
416 //Timezone. The post date is adjusted by the timezone offset in the cff_getdate function.
417 $cff_timezone = $atts['timezone'];
418
419 //Posted ago strings
420 $cff_date_translate_strings = array(
421 'cff_translate_second' => $atts['secondtext'],
422 'cff_translate_seconds' => $atts['secondstext'],
423 'cff_translate_minute' => $atts['minutetext'],
424 'cff_translate_minutes' => $atts['minutestext'],
425 'cff_translate_hour' => $atts['hourtext'],
426 'cff_translate_hours' => $atts['hourstext'],
427 'cff_translate_day' => $atts['daytext'],
428 'cff_translate_days' => $atts['daystext'],
429 'cff_translate_week' => $atts['weektext'],
430 'cff_translate_weeks' => $atts['weekstext'],
431 'cff_translate_month' => $atts['monthtext'],
432 'cff_translate_months' => $atts['monthstext'],
433 'cff_translate_year' => $atts['yeartext'],
434 'cff_translate_years' => $atts['yearstext'],
435 'cff_translate_ago' => $atts['agotext']
436 );
437 $cff_date_formatting = $atts[ 'dateformat' ];
438 $cff_date_custom = $atts[ 'datecustom' ];
439
440 $post_time = isset($news->created_time) ? $news->created_time : '';
441 $post_time = isset($news->backdated_time) ? $news->backdated_time : $post_time; //If the post is backdated then use that as the date instead
442 return $cff_date_before . ' ' .CFF_Utils::cff_getdate(strtotime($post_time), $cff_date_formatting, $cff_date_custom, $cff_date_translate_strings, $cff_timezone) . ' ' . $cff_date_after;
443 }
444
445 /**
446 *
447 * Get Media Link Data
448 * Get the Media link data for the templates
449 *
450 * @since 2.19
451 * -----------------------------------------
452 */
453 static function get_media_link_text( $atts, $cff_post_type, $cff_album ){
454 $cff_translate_photo_text = CFF_Utils::return_value($atts['phototext'], esc_html__('Photo', 'custom-facebook-feed'));
455 $cff_translate_video_text = CFF_Utils::return_value($atts['videotext'], esc_html__('Video', 'custom-facebook-feed'));
456 return ( $cff_post_type == 'photo' || $cff_album ) ? $cff_translate_photo_text : $cff_translate_video_text;
457 }
458
459 static function get_media_link_icon( $cff_post_type, $cff_album ){
460 return ( $cff_post_type == 'photo' || $cff_album ) ? 'picture-o fa-image' : 'video-camera fa-video';
461 }
462
463
464 /**
465 *
466 * Get Post Link Data
467 * Get the Post link data for the templates
468 *
469 * @since 2.19
470 * -----------------------------------------
471 */
472 static function get_post_link_social_links( $link, $cff_post_text_to_share ){
473 return [
474 'facebook' => [
475 'icon' => 'facebook-square',
476 'text' => esc_html__('Share on Facebook', 'custom-facebook-feed'),
477 'share_link' => 'https://www.facebook.com/sharer/sharer.php?u=' . urlencode($link)
478 ],
479 'twitter' => [
480 'icon' => 'twitter',
481 'text' => esc_html__('Share on Twitter', 'custom-facebook-feed'),
482 'share_link' => 'https://twitter.com/intent/tweet?text=' . urlencode($link)
483 ],
484 'linkedin' => [
485 'icon' => 'linkedin',
486 'text' => esc_html__('Share on Linked In', 'custom-facebook-feed'),
487 'share_link' => 'https://www.linkedin.com/shareArticle?mini=true&amp;url=' . urlencode($link) . '&amp;title=' . rawurlencode( strip_tags($cff_post_text_to_share) )
488 ],
489 'email' => [
490 'icon' => 'envelope',
491 'text' => esc_html__('Share by Email', 'custom-facebook-feed'),
492 'share_link' => 'mailto:?subject=Facebook&amp;body=' . urlencode($link) . '%20-%20' . rawurlencode( strip_tags($cff_post_text_to_share) )
493 ]
494 ];
495 }
496
497 static function get_post_link_text_to_share( $cff_post_text ){
498 $cff_post_text_to_share = '';
499 if( strpos($cff_post_text, '<span class="cff-expand">') !== false ){
500 $cff_post_text_to_share = explode('<span class="cff-expand">', $cff_post_text);
501 if( is_array($cff_post_text_to_share) ) $cff_post_text_to_share = $cff_post_text_to_share[0];
502 }
503 return $cff_post_text_to_share;
504 }
505
506 static function get_post_link_text_link( $atts, $cff_post_type ){
507 $cff_facebook_link_text = $atts[ 'facebooklinktext' ];
508 $link_text = ($cff_facebook_link_text != '' && !empty($cff_facebook_link_text)) ? $cff_facebook_link_text : esc_html__('View on Facebook', 'custom-facebook-feed');
509 //If it's an offer post then change the text
510 if ($cff_post_type == 'offer') $link_text = esc_html__('View Offer', 'custom-facebook-feed');
511 return $link_text;
512 }
513
514 static function get_post_link_fb_share_text( $atts ){
515 return ( $atts[ 'sharelinktext' ] ) ? $atts[ 'sharelinktext' ] : esc_html__('Share', 'custom-facebook-feed');
516 }
517
518
519 /**
520 *
521 * Get Post Text Data
522 * Get the Post text data for the templates
523 *
524 * @since 2.19
525 * -----------------------------------------
526 */
527 static function get_post_text_title_format( $atts ){
528 return ( empty($atts[ 'textformat' ]) || $atts[ 'textformat' ] == 'p' ) ? 'div' : $atts[ 'textformat' ];
529 }
530
531 static function get_post_text_link( $cff_post_type, $this_class, $link, $PostID ){
532 return ( $cff_post_type == 'link' || $cff_post_type == 'video' ) ? "https://www.facebook.com/" . $this_class->page_id . "/posts/" . $PostID[1] : $link;
533 }
534
535 static function get_post_text_contenttext( $post_text, $cff_linebreak_el, $cff_title_link ){
536 //Replace line breaks in text (needed for IE8 and to prevent lost line breaks in HTML minification)
537 $post_text = preg_replace("/\r\n|\r|\n/",$cff_linebreak_el, $post_text);
538 //If the text is wrapped in a link then don't hyperlink any text within
539 if( $cff_title_link ):
540 //Remove links from text
541 $result = preg_replace('/<a href=\"(.*?)\">(.*?)<\/a>/', "\\2", $post_text);
542 return CFF_Utils::cff_wrap_span( $result ) . ' ';;
543 else :
544 return CFF_Autolink::cff_autolink( $post_text );
545 endif;
546 }
547
548 static function get_post_text_call_to_actions( $atts, $news, $cff_title_styles, $cff_posttext_link_color, $cff_nofollow_referrer){
549 //Add a call to action button if included
550 if( isset($news->call_to_action->value->link) ){
551 $cff_cta_link = $news->call_to_action->value->link;
552
553 if( $cff_cta_link[0] == '/' ){
554 $cff_cta_link = 'https://facebook.com' . $cff_cta_link;
555 } else {
556 //If it doesn't start with 'http' then add it otherwise the link doesn't work. Don't do this if it's a tel num.
557 if (strpos($cff_cta_link, 'http') === false && strpos($cff_cta_link, 'tel:') === false) $cff_cta_link = 'http://' . $cff_cta_link;
558 }
559
560 $cff_button_type = $news->call_to_action->type;
561
562 switch ($cff_button_type) {
563 case 'SHOP_NOW':
564 $cff_cta_button_text = CFF_Utils::return_value( $atts['shopnowtext'], 'Shop Now');
565 break;
566 case 'MESSAGE_PAGE':
567 $cff_cta_button_text = CFF_Utils::return_value( $atts['messagepage'], 'Message Page');
568 break;
569 case 'LEARN_MORE':
570 $cff_cta_button_text = CFF_Utils::return_value( $atts['learnmoretext'], 'Learn More');
571 break;
572 default:
573 $cff_cta_button_text = ucwords(strtolower( str_replace('_',' ',$cff_button_type) ) );
574 }
575
576 $cff_app_link = isset($news->call_to_action->value->app_link) ? $news->call_to_action->value->app_link : '';
577
578 // Set the message page cta to use the default messenger link as the API can sometimes send an invalid link
579 if ( $cff_button_type == 'MESSAGE_PAGE' ) $cff_cta_link = 'https://m.me/' . $news->from->id;
580
581 //Add the button to the post if the text isn't "NO_BUTTON"
582 if( $cff_button_type != 'NO_BUTTON' ):
583 ?>
584 <p class="cff-cta-link" <?php echo $cff_title_styles ?>><a href="<?php echo esc_url($cff_cta_link) ?>" target="_blank" data-app-link="<?php echo $cff_app_link ?>" style="color: #<?php echo $cff_posttext_link_color ?>;" <?php echo $cff_nofollow_referrer ?> ><?php echo $cff_cta_button_text ?></a></p>
585 <?php
586 endif;
587 }
588 }
589
590
591 /**
592 *
593 * Get Shared Link Data
594 * Get the Shared Link data for the templates
595 *
596 * @since 2.19
597 * -----------------------------------------
598 */
599 static function get_shared_link_caption( $news ){
600 $cff_link_caption = '';
601 if( !empty($news->link) ){
602 $cff_link_caption = htmlentities($news->link, ENT_QUOTES, 'UTF-8');
603 $cff_link_caption_parts = explode('/', $cff_link_caption);
604 if( isset($cff_link_caption_parts[2]) ) $cff_link_caption = $cff_link_caption_parts[2];
605 }
606 return $cff_link_caption;
607 }
608
609 static function get_shared_link_title_format( $atts ){
610 return ( empty( $atts[ 'linktitleformat' ] ) ) ? 'p' : $atts[ 'linktitleformat' ];
611 }
612
613 static function get_shared_link_title_styles( $atts ){
614 return ( !empty($atts[ 'linktitlesize' ]) && $atts[ 'linktitlesize' ] != 'inherit' ) ? 'style="font-size:' . $atts[ 'linktitlesize' ] . 'px;"' : '';
615 }
616
617
618 static function get_shared_link_description_text( $body_limit, $description_text, $cff_title_link, $cff_posttext_link_color ){
619 //Truncate desc
620 if (!empty($body_limit)) {
621 if (strlen($description_text) > $body_limit) $description_text = substr($description_text, 0, $body_limit) . '...';
622 }
623 if ($cff_title_link) {
624 }else{
625 $description_text = CFF_Autolink::cff_autolink( htmlspecialchars($description_text), $link_color = $cff_posttext_link_color );
626 }
627 return $description_text;
628 }
629
630 static function get_shared_link_description( $cff_title_link, $description_text ){
631 $cff_link_description = '';
632 if ($cff_title_link) {
633 $cff_link_description = CFF_Utils::cff_wrap_span( htmlspecialchars($description_text) );
634 }else{
635 $cff_link_description = nl2br($description_text);
636 }
637 return $cff_link_description ;
638 }
639
640
641
642 /**
643 *
644 * Get Error Message Data
645 * Get the error message data for the templates
646 *
647 * @since 2.19
648 * -----------------------------------------
649 */
650
651 static function get_error_check( $page_id, $user_id, $access_token ){
652 $cff_ppca_check_error = false;
653 if( ! get_user_meta($user_id, 'cff_ppca_check_notice_dismiss') ){
654 $cff_posts_json_url = 'https://graph.facebook.com/v8.0/'.$page_id.'/posts?limit=1&access_token='.$access_token;
655 $transient_name = 'cff_ppca_' . substr($page_id, 0, 5) . substr($page_id, strlen($page_id)-5, 5) . '_' . substr($access_token, 15, 10);
656 $cff_cache_time = 1;
657 $cache_seconds = YEAR_IN_SECONDS;
658 $cff_ppca_check = CFF_Utils::cff_get_set_cache($cff_posts_json_url, $transient_name, $cff_cache_time, $cache_seconds, '', true, $access_token, $backup=false);
659 $cff_ppca_check_json = json_decode($cff_ppca_check);
660
661 if( isset( $cff_ppca_check_json->error ) && strpos($cff_ppca_check_json->error->message, 'Public Content Access') !== false ){
662 $cff_ppca_check_error = true;
663 }
664 }
665 return $cff_ppca_check_error;
666 }
667
668 static function get_error_message_cap( ){
669 $cap = current_user_can( 'manage_custom_facebook_feed_options' ) ? 'manage_custom_facebook_feed_options' : 'manage_options';
670 $cap = apply_filters( 'cff_settings_pages_capability', $cap );
671 return $cap;
672 }
673
674 static function get_error_check_ppca( $FBdata ){
675 //Is it a PPCA error from the API?
676 return ( isset($FBdata->error->message) && strpos($FBdata->error->message, 'Public Content Access') !== false ) ? true : false;
677 }
678
679
680
681 /**
682 *
683 * Get Likebox Data
684 * Get the likebox data for the templates
685 *
686 * @since 2.19
687 * -----------------------------------------
688 */
689
690 static function get_likebox_height( $atts, $cff_like_box_small_header, $cff_like_box_faces ){
691 $cff_likebox_height = $atts[ 'likeboxheight' ];
692 $cff_likebox_height = preg_replace('/px$/', '', $cff_likebox_height);
693 //Calculate the like box height
694 $cff_likebox_height = 130;
695 if( $cff_like_box_small_header == 'true' ) $cff_likebox_height = 70;
696 if( $cff_like_box_faces == 'true' ) $cff_likebox_height = 214;
697 if( $cff_like_box_small_header == 'true' && $cff_like_box_faces == 'true' ) $cff_likebox_height = 154;
698 return $cff_likebox_height;
699 }
700
701
702 static function get_likebox_width( $atts ){
703 $cff_likebox_custom_width = isset( $atts[ 'likeboxcustomwidth' ] ) ? CFF_Utils::check_if_on($atts[ 'likeboxcustomwidth' ]) : false;
704 $cff_likebox_width = $cff_likebox_custom_width && isset($atts[ 'likeboxwidth' ]) && !empty($atts[ 'likeboxwidth' ]) ? $atts[ 'likeboxwidth' ] : 300;
705 return $cff_likebox_width;
706 }
707
708 static function get_likebox_classes( $atts ){
709 return "cff-likebox" . ( CFF_Utils::check_if_on($atts[ 'likeboxoutside' ]) ? " cff-outside" : '' ) . ( $atts[ 'likeboxpos' ] == 'top' ? ' cff-top' : ' cff-bottom' );
710 }
711
712 static function get_likebox_tag( $atts ){
713 return ( $atts[ 'likeboxpos' ] == 'top') ? 'section' : 'div';
714 }
715
716
717 /**
718 *
719 * Get Header Data
720 * Get the Header data for the templates
721 *
722 * @since 2.19
723 * -----------------------------------------
724 */
725 static function get_header_txt_classes( $cff_header_outside ){
726 return ($cff_header_outside) ? " cff-outside" : '';
727 }
728
729
730 static function get_header_parts( $atts ){
731 if ( !empty( $atts['headerinc'] ) || !empty( $atts['headerexclude'] ) ) {
732 if ( !empty( $atts['headerinc'] ) ) {
733 $header_inc = explode( ',', str_replace( ' ', '', strtolower( $atts['headerinc'] ) ) );
734 $cff_header_cover = in_array( 'cover', $header_inc, true );
735 $cff_header_name = in_array( 'name', $header_inc, true );
736 $cff_header_bio = in_array( 'about', $header_inc, true );
737 } else {
738 $header_exc = explode( ',', str_replace( ' ', '', strtolower( $atts['headerexclude'] ) ) );
739 $cff_header_cover = ! in_array( 'cover', $header_exc, true );
740 $cff_header_name = ! in_array( 'name', $header_exc, true );
741 $cff_header_bio = ! in_array( 'about', $header_exc, true );
742 }
743 }else{
744 $cff_header_cover = CFF_Utils::check_if_on( $atts['headercover'] );
745 $cff_header_name = CFF_Utils::check_if_on( $atts['headername'] );
746 $cff_header_bio = CFF_Utils::check_if_on( $atts['headerbio'] );
747 }
748
749 return [
750 'cover' => $cff_header_cover,
751 'name' => $cff_header_name,
752 'bio' => $cff_header_bio
753 ];
754 }
755
756 static function get_header_height_style( $atts ){
757 $cff_header_cover_height = ! empty( $atts['headercoverheight'] ) ? (int)$atts['headercoverheight'] : 300;
758 $header_hero_style = $cff_header_cover_height !== 300 ? ' style="height: '.$cff_header_cover_height.'px";' : '';
759 return $header_hero_style;
760 }
761
762 static function get_header_font_size( $atts ){
763 return !empty($atts['headertextsize']) ? 'style="font-size:'. $atts['headertextsize'] .'px;"' : '';
764 }
765
766 static function get_header_link( $header_data, $page_id ){
767 $link = CFF_Parse::get_link( $header_data );
768 if( $link == 'https://facebook.com' ) $link .= '/'.$page_id;
769 return $link;
770 }
771
772 public static function avatar_src( $header_data, $atts ) {
773 if ( CFF_GDPR_Integrations::doing_gdpr( $atts ) ) {
774 return trailingslashit( CFF_PLUGIN_URL ) . 'assets/img/placeholder.png';
775 }
776 return CFF_Parse::get_avatar( $header_data );
777 }
778
779 public static function cover_image_src( $header_data, $atts ) {
780 if ( CFF_GDPR_Integrations::doing_gdpr( $atts ) ) {
781 return trailingslashit( CFF_PLUGIN_URL ) . 'assets/img/placeholder.png';
782 }
783 return CFF_Parse::get_cover_source( $header_data );
784 }
785
786 /*
787 *
788 * PRINT THE GDPR NTOCE FOR ADMINS IN THE FRON END
789 *
790 */
791 static function print_gdpr_notice($element_name, $custom_class = ''){
792 if ( ! is_user_logged_in() || ! current_user_can( 'edit_posts' )) {
793 return;
794 }
795 ?>
796 <div class="cff-gdpr-notice <?php echo $custom_class; ?>">
797 <i class="fa fa-lock" aria-hidden="true"></i>
798 <?php echo esc_html__('This notice is visible to admins only.','custom-facebook-feed') ?><br/>
799 <?php echo $element_name.' '.esc_html__('disabled due to GDPR setting.','custom-facebook-feed') ?> <a href="<?php echo esc_url(admin_url('admin.php?page=cff-style&tab=misc')); ?>"><?php echo esc_html__('Click here','custom-facebook-feed') ?></a> <?php echo esc_html__('for more info.','custom-facebook-feed') ?>
800 </div>
801 <?php
802 }
803
804 }
805