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