PluginProbe ʕ •ᴥ•ʔ
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress / 1.7.0
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress v1.7.0
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 / custom-facebook-feed.php
custom-facebook-feed Last commit date
css 12 years ago img 12 years ago js 12 years ago README.txt 12 years ago custom-facebook-feed-admin.php 12 years ago custom-facebook-feed.php 12 years ago gpl-2.0.txt 13 years ago
custom-facebook-feed.php
1316 lines
1 <?php
2 /*
3 Plugin Name: Custom Facebook Feed
4 Plugin URI: http://smashballoon.com/custom-facebook-feed
5 Description: Add a completely customizable Facebook feed to your WordPress site
6 Version: 1.7.0
7 Author: Smash Balloon
8 Author URI: http://smashballoon.com/
9 License: GPLv2 or later
10 */
11 /*
12 Copyright 2013 Smash Balloon LLC (email : hey@smashballoon.com)
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25 //Include admin
26 include dirname( __FILE__ ) .'/custom-facebook-feed-admin.php';
27
28 // Add shortcodes
29 add_shortcode('custom-facebook-feed', 'display_cff');
30 function display_cff($atts) {
31
32 //Style options
33 $options = get_option('cff_style_settings');
34 //Create the types string to set as shortcode default
35 $include_string = '';
36 if($options[ 'cff_show_text' ]) $include_string .= 'text,';
37 if($options[ 'cff_show_desc' ]) $include_string .= 'desc,';
38 if($options[ 'cff_show_shared_links' ]) $include_string .= 'sharedlinks,';
39 if($options[ 'cff_show_date' ]) $include_string .= 'date,';
40 if($options[ 'cff_show_media' ]) $include_string .= 'media,';
41 if($options[ 'cff_show_event_title' ]) $include_string .= 'eventtitle,';
42 if($options[ 'cff_show_event_details' ]) $include_string .= 'eventdetails,';
43 if($options[ 'cff_show_meta' ]) $include_string .= 'social,';
44 if($options[ 'cff_show_link' ]) $include_string .= 'link,';
45 if($options[ 'cff_show_like_box' ]) $include_string .= 'likebox,';
46 //Pass in shortcode attrbutes
47 $atts = shortcode_atts(
48 array(
49 'id' => get_option('cff_page_id'),
50 'pagetype' => get_option('cff_page_type'),
51 'num' => get_option('cff_num_show'),
52 'limit' => get_option('cff_post_limit'),
53 'others' => '',
54 'showpostsby' => get_option('cff_show_others'),
55 'cachetime' => get_option('cff_cache_time'),
56 'cacheunit' => get_option('cff_cache_time_unit'),
57 'locale' => get_option('cff_locale'),
58 'width' => isset($options[ 'cff_feed_width' ]) ? $options[ 'cff_feed_width' ] : '',
59 'height' => isset($options[ 'cff_feed_height' ]) ? $options[ 'cff_feed_height' ] : '',
60 'padding' => isset($options[ 'cff_feed_padding' ]) ? $options[ 'cff_feed_padding' ] : '',
61 'bgcolor' => isset($options[ 'cff_bg_color' ]) ? $options[ 'cff_bg_color' ] : '',
62 'showauthor' => isset($options[ 'cff_show_author' ]) ? $options[ 'cff_show_author' ] : '',
63 'class' => isset($options[ 'cff_class' ]) ? $options[ 'cff_class' ] : '',
64 'layout' => isset($options[ 'cff_preset_layout' ]) ? $options[ 'cff_preset_layout' ] : '',
65 'include' => $include_string,
66 //Typography
67 'textformat' => isset($options[ 'cff_title_format' ]) ? $options[ 'cff_title_format' ] : '',
68 'textsize' => isset($options[ 'cff_title_size' ]) ? $options[ 'cff_title_size' ] : '',
69 'textweight' => isset($options[ 'cff_title_weight' ]) ? $options[ 'cff_title_weight' ] : '',
70 'textcolor' => isset($options[ 'cff_title_color' ]) ? $options[ 'cff_title_color' ] : '',
71 'textlink' => isset($options[ 'cff_title_link' ]) ? $options[ 'cff_title_link' ] : '',
72 'descsize' => isset($options[ 'cff_body_size' ]) ? $options[ 'cff_body_size' ] : '',
73 'descweight' => isset($options[ 'cff_body_weight' ]) ? $options[ 'cff_body_weight' ] : '',
74 'desccolor' => isset($options[ 'cff_body_color' ]) ? $options[ 'cff_body_color' ] : '',
75 //Event title
76 'eventtitleformat' => isset($options[ 'cff_event_title_format' ]) ? $options[ 'cff_event_title_format' ] : '',
77 'eventtitlesize' => isset($options[ 'cff_event_title_size' ]) ? $options[ 'cff_event_title_size' ] : '',
78 'eventtitleweight' => isset($options[ 'cff_event_title_weight' ]) ? $options[ 'cff_event_title_weight' ] : '',
79 'eventtitlecolor' => isset($options[ 'cff_event_title_color' ]) ? $options[ 'cff_event_title_color' ] : '',
80 'eventtitlelink' => isset($options[ 'cff_event_title_link' ]) ? $options[ 'cff_event_title_link' ] : '',
81 //Event date
82 'eventdatesize' => isset($options[ 'cff_event_date_size' ]) ? $options[ 'cff_event_date_size' ] : '',
83 'eventdateweight' => isset($options[ 'cff_event_date_weight' ]) ? $options[ 'cff_event_date_weight' ] : '',
84 'eventdatecolor' => isset($options[ 'cff_event_date_color' ]) ? $options[ 'cff_event_date_color' ] : '',
85 'eventdatepos' => isset($options[ 'cff_event_date_position' ]) ? $options[ 'cff_event_date_position' ] : '',
86 'eventdateformat' => isset($options[ 'cff_event_date_formatting' ]) ? $options[ 'cff_event_date_formatting' ] : '',
87 'eventdatecustom' => isset($options[ 'cff_event_date_custom' ]) ? $options[ 'cff_event_date_custom' ] : '',
88 //Event details
89 'eventdetailssize' => isset($options[ 'cff_event_details_size' ]) ? $options[ 'cff_event_details_size' ] : '',
90 'eventdetailsweight' => isset($options[ 'cff_event_details_weight' ]) ? $options[ 'cff_event_details_weight' ] : '',
91 'eventdetailscolor' => isset($options[ 'cff_event_details_color' ]) ? $options[ 'cff_event_details_color' ] : '',
92 //Date
93 'datepos' => isset($options[ 'cff_date_position' ]) ? $options[ 'cff_date_position' ] : '',
94 'datesize' => isset($options[ 'cff_date_size' ]) ? $options[ 'cff_date_size' ] : '',
95 'dateweight' => isset($options[ 'cff_date_weight' ]) ? $options[ 'cff_date_weight' ] : '',
96 'datecolor' => isset($options[ 'cff_date_color' ]) ? $options[ 'cff_date_color' ] : '',
97 'dateformat' => isset($options[ 'cff_date_formatting' ]) ? $options[ 'cff_date_formatting' ] : '',
98 'datecustom' => isset($options[ 'cff_date_custom' ]) ? $options[ 'cff_date_custom' ] : '',
99 'timezone' => isset($options[ 'cff_timezone' ]) ? $options[ 'cff_timezone' ] : 'America/Chicago',
100
101 //Link to Facebook
102 'linksize' => isset($options[ 'cff_link_size' ]) ? $options[ 'cff_link_size' ] : '',
103 'linkweight' => isset($options[ 'cff_link_weight' ]) ? $options[ 'cff_link_weight' ] : '',
104 'linkcolor' => isset($options[ 'cff_link_color' ]) ? $options[ 'cff_link_color' ] : '',
105 'viewlinktext' => isset($options[ 'cff_view_link_text' ]) ? $options[ 'cff_view_link_text' ] : '',
106 'linktotimeline' => isset($options[ 'cff_link_to_timeline' ]) ? $options[ 'cff_link_to_timeline' ] : '',
107 //Social
108 'iconstyle' => isset($options[ 'cff_icon_style' ]) ? $options[ 'cff_icon_style' ] : '',
109 'socialtextcolor' => isset($options[ 'cff_meta_text_color' ]) ? $options[ 'cff_meta_text_color' ] : '',
110 'socialbgcolor' => isset($options[ 'cff_meta_bg_color' ]) ? $options[ 'cff_meta_bg_color' ] : '',
111 //Misc
112 'textlength' => get_option('cff_title_length'),
113 'desclength' => get_option('cff_body_length'),
114 'likeboxpos' => isset($options[ 'cff_like_box_position' ]) ? $options[ 'cff_like_box_position' ] : '',
115 'likeboxoutside' => isset($options[ 'cff_like_box_outside' ]) ? $options[ 'cff_like_box_outside' ] : '',
116 'likeboxcolor' => isset($options[ 'cff_likebox_bg_color' ]) ? $options[ 'cff_likebox_bg_color' ] : '',
117 'likeboxtextcolor' => isset($options[ 'cff_like_box_text_color' ]) ? $options[ 'cff_like_box_text_color' ] : '',
118 'likeboxwidth' => isset($options[ 'cff_likebox_width' ]) ? $options[ 'cff_likebox_width' ] : '',
119 'likeboxfaces' => isset($options[ 'cff_like_box_faces' ]) ? $options[ 'cff_like_box_faces' ] : '',
120 'likeboxborder' => isset($options[ 'cff_like_box_border' ]) ? $options[ 'cff_like_box_border' ] : '',
121
122 //Page Header
123 'showheader' => isset($options[ 'cff_show_header' ]) ? $options[ 'cff_show_header' ] : '',
124 'headeroutside' => isset($options[ 'cff_header_outside' ]) ? $options[ 'cff_header_outside' ] : '',
125 'headertext' => isset($options[ 'cff_header_text' ]) ? $options[ 'cff_header_text' ] : '',
126 'headerbg' => isset($options[ 'cff_header_bg_color' ]) ? $options[ 'cff_header_bg_color' ] : '',
127 'headerpadding' => isset($options[ 'cff_header_padding' ]) ? $options[ 'cff_header_padding' ] : '',
128 'headertextsize' => isset($options[ 'cff_header_text_size' ]) ? $options[ 'cff_header_text_size' ] : '',
129 'headertextweight' => isset($options[ 'cff_header_text_weight' ]) ? $options[ 'cff_header_text_weight' ] : '',
130 'headertextcolor' => isset($options[ 'cff_header_text_color' ]) ? $options[ 'cff_header_text_color' ] : '',
131 'headericon' => isset($options[ 'cff_header_icon' ]) ? $options[ 'cff_header_icon' ] : '',
132 'headericoncolor' => isset($options[ 'cff_header_icon_color' ]) ? $options[ 'cff_header_icon_color' ] : '',
133 'headericonsize' => isset($options[ 'cff_header_icon_size' ]) ? $options[ 'cff_header_icon_size' ] : '',
134
135 'videoheight' => isset($options[ 'cff_video_height' ]) ? $options[ 'cff_video_height' ] : '',
136 'videoaction' => isset($options[ 'cff_video_action' ]) ? $options[ 'cff_video_action' ] : '',
137 'sepcolor' => isset($options[ 'cff_sep_color' ]) ? $options[ 'cff_sep_color' ] : '',
138 'sepsize' => isset($options[ 'cff_sep_size' ]) ? $options[ 'cff_sep_size' ] : '',
139
140 //Translate
141 'seemoretext' => isset($options[ 'cff_see_more_text' ]) ? $options[ 'cff_see_more_text' ] : '',
142 'seelesstext' => isset($options[ 'cff_see_less_text' ]) ? $options[ 'cff_see_less_text' ] : '',
143 'facebooklinktext' => isset($options[ 'cff_facebook_link_text' ]) ? $options[ 'cff_facebook_link_text' ] : '',
144 'photostext' => isset($options[ 'cff_translate_photos_text' ]) ? $options[ 'cff_translate_photos_text' ] : ''
145 ), $atts);
146 /********** GENERAL **********/
147 $cff_page_type = $atts[ 'pagetype' ];
148 ($cff_page_type == 'group') ? $cff_is_group = true : $cff_is_group = false;
149
150 $cff_post_limit = $atts[ 'limit' ];
151
152 $cff_feed_width = $atts['width'];
153 $cff_feed_height = $atts[ 'height' ];
154 $cff_feed_padding = $atts[ 'padding' ];
155 $cff_bg_color = $atts[ 'bgcolor' ];
156 $cff_show_author = $atts[ 'showauthor' ];
157 $cff_cache_time = $atts[ 'cachetime' ];
158 $cff_locale = $atts[ 'locale' ];
159 if ( empty($cff_locale) || !isset($cff_locale) || $cff_locale == '' ) $cff_locale = 'en_US';
160 if (!isset($cff_cache_time)) $cff_cache_time = 0;
161 $cff_cache_time_unit = $atts[ 'cacheunit' ];
162 $cff_class = $atts['class'];
163 //Compile feed styles
164 $cff_feed_styles = 'style="';
165 if ( !empty($cff_feed_width) ) $cff_feed_styles .= 'width:' . $cff_feed_width . '; ';
166 if ( !empty($cff_feed_height) ) $cff_feed_styles .= 'height:' . $cff_feed_height . '; ';
167 if ( !empty($cff_feed_padding) ) $cff_feed_styles .= 'padding:' . $cff_feed_padding . '; ';
168 if ( !empty($cff_bg_color) ) $cff_feed_styles .= 'background-color:#' . $cff_bg_color . '; ';
169 $cff_feed_styles .= '"';
170 //Like box
171 $cff_like_box_position = $atts[ 'likeboxpos' ];
172 $cff_like_box_outside = $atts[ 'likeboxoutside' ];
173 //Open links in new window?
174 $target = 'target="_blank"';
175 /********** POST TYPES **********/
176 $cff_show_links_type = true;
177 $cff_show_event_type = true;
178 $cff_show_video_type = true;
179 $cff_show_photos_type = true;
180 $cff_show_status_type = true;
181 $cff_events_only = false;
182 //Are we showing ONLY events?
183 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;
184 /********** LAYOUT **********/
185 $cff_includes = $atts[ 'include' ];
186 //Look for non-plural version of string in the types string in case user specifies singular in shortcode
187 $cff_show_text = false;
188 $cff_show_desc = false;
189 $cff_show_shared_links = false;
190 $cff_show_date = false;
191 $cff_show_media = false;
192 $cff_show_event_title = false;
193 $cff_show_event_details = false;
194 $cff_show_meta = false;
195 $cff_show_link = false;
196 $cff_show_like_box = false;
197 if ( stripos($cff_includes, 'text') !== false ) $cff_show_text = true;
198 if ( stripos($cff_includes, 'desc') !== false ) $cff_show_desc = true;
199 if ( stripos($cff_includes, 'sharedlink') !== false ) $cff_show_shared_links = true;
200 if ( stripos($cff_includes, 'date') !== false ) $cff_show_date = true;
201 if ( stripos($cff_includes, 'media') !== false ) $cff_show_media = true;
202 if ( stripos($cff_includes, 'eventtitle') !== false ) $cff_show_event_title = true;
203 if ( stripos($cff_includes, 'eventdetail') !== false ) $cff_show_event_details = true;
204 if ( stripos($cff_includes, 'social') !== false ) $cff_show_meta = true;
205 if ( stripos($cff_includes, ',link') !== false ) $cff_show_link = true; //comma used to separate it from 'sharedlinks' - which also contains 'link' string
206 if ( stripos($cff_includes, 'like') !== false ) $cff_show_like_box = true;
207 $cff_preset_layout = 'thumb';
208
209 /********** META **********/
210 $cff_icon_style = $atts[ 'iconstyle' ];
211 $cff_meta_text_color = $atts[ 'socialtextcolor' ];
212 $cff_meta_bg_color = $atts[ 'socialbgcolor' ];
213 $cff_meta_styles = 'style="';
214 if ( !empty($cff_meta_text_color) ) $cff_meta_styles .= 'color:#' . $cff_meta_text_color . ';';
215 if ( !empty($cff_meta_bg_color) ) $cff_meta_styles .= 'background-color:#' . $cff_meta_bg_color . ';';
216 $cff_meta_styles .= '"';
217 $cff_nocomments_text = isset($options[ 'cff_nocomments_text' ]) ? $options[ 'cff_nocomments_text' ] : '';
218 $cff_hide_comments = isset($options[ 'cff_hide_comments' ]) ? $options[ 'cff_hide_comments' ] : '';
219 if (!isset($cff_nocomments_text) || empty($cff_nocomments_text)) $cff_hide_comments = true;
220 /********** TYPOGRAPHY **********/
221 //See More text
222 $cff_see_more_text = $atts[ 'seemoretext' ];
223 $cff_see_less_text = $atts[ 'seelesstext' ];
224 //See Less text
225 //Title
226 $cff_title_format = $atts[ 'textformat' ];
227 if (empty($cff_title_format)) $cff_title_format = 'p';
228 $cff_title_size = $atts[ 'textsize' ];
229 $cff_title_weight = $atts[ 'textweight' ];
230 $cff_title_color = $atts[ 'textcolor' ];
231 $cff_title_styles = 'style="';
232 if ( !empty($cff_title_size) && $cff_title_size != 'inherit' ) $cff_title_styles .= 'font-size:' . $cff_title_size . 'px; ';
233 if ( !empty($cff_title_weight) && $cff_title_weight != 'inherit' ) $cff_title_styles .= 'font-weight:' . $cff_title_weight . '; ';
234 if ( !empty($cff_title_color) ) $cff_title_styles .= 'color:#' . $cff_title_color . ';';
235 $cff_title_styles .= '"';
236 $cff_title_link = $atts[ 'textlink' ];
237 //Description
238 $cff_body_size = $atts[ 'descsize' ];
239 $cff_body_weight = $atts[ 'descweight' ];
240 $cff_body_color = $atts[ 'desccolor' ];
241 $cff_body_styles = 'style="';
242 if ( !empty($cff_body_size) && $cff_body_size != 'inherit' ) $cff_body_styles .= 'font-size:' . $cff_body_size . 'px; ';
243 if ( !empty($cff_body_weight) && $cff_body_weight != 'inherit' ) $cff_body_styles .= 'font-weight:' . $cff_body_weight . '; ';
244 if ( !empty($cff_body_color) ) $cff_body_styles .= 'color:#' . $cff_body_color . ';';
245 $cff_body_styles .= '"';
246 //Event Title
247 $cff_event_title_format = $atts[ 'eventtitleformat' ];
248 if (empty($cff_event_title_format)) $cff_event_title_format = 'p';
249 $cff_event_title_size = $atts[ 'eventtitlesize' ];
250 $cff_event_title_weight = $atts[ 'eventtitleweight' ];
251 $cff_event_title_color = $atts[ 'eventtitlecolor' ];
252 $cff_event_title_styles = 'style="';
253 if ( !empty($cff_event_title_size) && $cff_event_title_size != 'inherit' ) $cff_event_title_styles .= 'font-size:' . $cff_event_title_size . 'px; ';
254 if ( !empty($cff_event_title_weight) && $cff_event_title_weight != 'inherit' ) $cff_event_title_styles .= 'font-weight:' . $cff_event_title_weight . '; ';
255 if ( !empty($cff_event_title_color) ) $cff_event_title_styles .= 'color:#' . $cff_event_title_color . ';';
256 $cff_event_title_styles .= '"';
257 $cff_event_title_link = $atts[ 'eventtitlelink' ];
258 //Event Date
259 $cff_event_date_size = $atts[ 'eventdatesize' ];
260 $cff_event_date_weight = $atts[ 'eventdateweight' ];
261 $cff_event_date_color = $atts[ 'eventdatecolor' ];
262 $cff_event_date_position = $atts[ 'eventdatepos' ];
263 $cff_event_date_formatting = $atts[ 'eventdateformat' ];
264 $cff_event_date_custom = $atts[ 'eventdatecustom' ];
265 $cff_event_date_styles = 'style="';
266 if ( !empty($cff_event_date_size) && $cff_event_date_size != 'inherit' ) $cff_event_date_styles .= 'font-size:' . $cff_event_date_size . 'px; ';
267 if ( !empty($cff_event_date_weight) && $cff_event_date_weight != 'inherit' ) $cff_event_date_styles .= 'font-weight:' . $cff_event_date_weight . '; ';
268 if ( !empty($cff_event_date_color) ) $cff_event_date_styles .= 'color:#' . $cff_event_date_color . ';';
269 $cff_event_date_styles .= '"';
270 //Event Details
271 $cff_event_details_size = $atts[ 'eventdetailssize' ];
272 $cff_event_details_weight = $atts[ 'eventdetailsweight' ];
273 $cff_event_details_color = $atts[ 'eventdetailscolor' ];
274 $cff_event_details_styles = 'style="';
275 if ( !empty($cff_event_details_size) && $cff_event_details_size != 'inherit' ) $cff_event_details_styles .= 'font-size:' . $cff_event_details_size . 'px; ';
276 if ( !empty($cff_event_details_weight) && $cff_event_details_weight != 'inherit' ) $cff_event_details_styles .= 'font-weight:' . $cff_event_details_weight . '; ';
277 if ( !empty($cff_event_details_color) ) $cff_event_details_styles .= 'color:#' . $cff_event_details_color . ';';
278 $cff_event_details_styles .= '"';
279 //Date
280 $cff_date_position = $atts[ 'datepos' ];
281 if (!isset($cff_date_position)) $cff_date_position = 'below';
282 $cff_date_size = $atts[ 'datesize' ];
283 $cff_date_weight = $atts[ 'dateweight' ];
284 $cff_date_color = $atts[ 'datecolor' ];
285 $cff_date_styles = 'style="';
286 if ( !empty($cff_date_size) && $cff_date_size != 'inherit' ) $cff_date_styles .= 'font-size:' . $cff_date_size . 'px; ';
287 if ( !empty($cff_date_weight) && $cff_date_weight != 'inherit' ) $cff_date_styles .= 'font-weight:' . $cff_date_weight . '; ';
288 if ( !empty($cff_date_color) ) $cff_date_styles .= 'color:#' . $cff_date_color . ';';
289 $cff_date_styles .= '"';
290 $cff_date_before = isset($options[ 'cff_date_before' ]) ? $options[ 'cff_date_before' ] : '';
291 $cff_date_after = isset($options[ 'cff_date_after' ]) ? $options[ 'cff_date_after' ] : '';
292 //Set user's timezone based on setting
293 $cff_timezone = $atts['timezone'];
294 date_default_timezone_set($cff_timezone);
295 //Link to Facebook
296 $cff_link_size = $atts[ 'linksize' ];
297 $cff_link_weight = $atts[ 'linkweight' ];
298 $cff_link_color = $atts[ 'linkcolor' ];
299 $cff_link_styles = 'style="';
300 if ( !empty($cff_link_size) && $cff_link_size != 'inherit' ) $cff_link_styles .= 'font-size:' . $cff_link_size . 'px; ';
301 if ( !empty($cff_link_weight) && $cff_link_weight != 'inherit' ) $cff_link_styles .= 'font-weight:' . $cff_link_weight . '; ';
302 if ( !empty($cff_link_color) ) $cff_link_styles .= 'color:#' . $cff_link_color . ';';
303 $cff_link_styles .= '"';
304 $cff_facebook_link_text = $atts[ 'facebooklinktext' ];
305 $cff_view_link_text = $atts[ 'viewlinktext' ];
306 $cff_link_to_timeline = $atts[ 'linktotimeline' ];
307 /********** MISC **********/
308 //Like Box styles
309 $cff_likebox_bg_color = $atts[ 'likeboxcolor' ];
310
311 $cff_like_box_text_color = $atts[ 'likeboxtextcolor' ];
312 $cff_like_box_colorscheme = 'light';
313 if ($cff_like_box_text_color == 'white') $cff_like_box_colorscheme = 'dark';
314
315 $cff_likebox_styles = 'style="';
316 if ( !empty($cff_likebox_bg_color) ) $cff_likebox_styles .= 'background-color:#' . $cff_likebox_bg_color . '; margin-left: 0; ';
317
318 $cff_likebox_width = $atts[ 'likeboxwidth' ];
319 if ( !isset($cff_likebox_width) || empty($cff_likebox_width) || $cff_likebox_width == '' ) $cff_likebox_width = '100%';
320 $cff_like_box_faces = $atts[ 'likeboxfaces' ];
321 if ( !isset($cff_like_box_faces) || empty($cff_like_box_faces) ) $cff_like_box_faces = 'false';
322 $cff_like_box_border = $atts[ 'likeboxborder' ];
323 if ($cff_like_box_border) {
324 $cff_like_box_border = 'true';
325 } else {
326 $cff_like_box_border = 'false';
327 }
328
329 //Compile Like box styles
330 $cff_likebox_styles = 'style="width: ' . $cff_likebox_width . ';';
331 if ( !empty($cff_likebox_bg_color) ) $cff_likebox_styles .= 'background-color: #' . $cff_likebox_bg_color . ';';
332 if ( empty($cff_likebox_bg_color) && $cff_like_box_faces == 'false' ) $cff_likebox_styles .= ' margin-left: -10px;';
333 $cff_likebox_styles .= '"';
334
335 //Get feed header settings
336 $cff_header_bg_color = $atts['headerbg'];
337 $cff_header_padding = $atts['headerpadding'];
338 $cff_header_text_size = $atts['headertextsize'];
339 $cff_header_text_weight = $atts['headertextweight'];
340 $cff_header_text_color = $atts['headertextcolor'];
341
342 //Compile feed header styles
343 $cff_header_styles = 'style="';
344 if ( !empty($cff_header_bg_color) ) $cff_header_styles .= 'background-color: #' . $cff_header_bg_color . ';';
345 if ( !empty($cff_header_padding) ) $cff_header_styles .= ' padding: ' . $cff_header_padding . ';';
346 if ( !empty($cff_header_text_size) ) $cff_header_styles .= ' font-size: ' . $cff_header_text_size . 'px;';
347 if ( !empty($cff_header_text_weight) ) $cff_header_styles .= ' font-weight: ' . $cff_header_text_weight . ';';
348 if ( !empty($cff_header_text_color) ) $cff_header_styles .= ' color: #' . $cff_header_text_color . ';';
349 $cff_header_styles .= '"';
350
351 //Video
352 //Dimensions
353 $cff_video_width = 640;
354 $cff_video_height = $atts[ 'videoheight' ];
355
356 //Action
357 $cff_video_action = $atts[ 'videoaction' ];
358 //Separating Line
359 $cff_sep_color = $atts[ 'sepcolor' ];
360 if (empty($cff_sep_color)) $cff_sep_color = 'ddd';
361 $cff_sep_size = $atts[ 'sepsize' ];
362 if (empty($cff_sep_size)) $cff_sep_size = 0;
363 //CFF item styles
364 $cff_item_styles = 'style="';
365 $cff_item_styles .= 'border-bottom: ' . $cff_sep_size . 'px solid #' . $cff_sep_color . '; ';
366 $cff_item_styles .= '"';
367
368 //Text limits
369 $title_limit = $atts['textlength'];
370 if (!isset($title_limit)) $title_limit = 9999;
371 $body_limit = $atts['desclength'];
372 //Assign the Access Token and Page ID variables
373 $access_token = trim( get_option('cff_access_token') );
374 $page_id = trim( $atts['id'] );
375 //Get show posts attribute. If not set then default to 25
376 $show_posts = $atts['num'];
377 if (empty($show_posts)) $show_posts = 25;
378 if ( $show_posts == 0 || $show_posts == 'undefined' ) $show_posts = 25;
379 //Check whether the Access Token is present and valid
380 if ($access_token == '') {
381 echo 'Please enter a valid Access Token. You can do this in the Custom Facebook Feed plugin settings.<br /><br />';
382 return false;
383 }
384 //Check whether a Page ID has been defined
385 if ($page_id == '') {
386 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=<b>YOUR_PAGE_ID</b>].<br /><br />";
387 return false;
388 }
389
390
391 //Is it SSL?
392 $cff_ssl = '';
393 if (is_ssl()) $cff_ssl = '&return_ssl_resources=true';
394
395 //Use posts? or feed?
396 $old_others_option = get_option('cff_show_others'); //Use this to help depreciate the old option
397 $show_others = $atts['others'];
398 $show_posts_by = $atts['showpostsby'];
399 $graph_query = 'posts';
400 $cff_show_only_others = false;
401
402 //If 'others' shortcode option is used then it overrides any other option
403 if ($show_others || $old_others_option == 'on') {
404 //Show posts by everyone
405 if ( $old_others_option == 'on' || $show_others == 'on' || $show_others == 'true' || $show_others == true || $cff_is_group ) $graph_query = 'feed';
406
407 //Only show posts by me
408 if ( $show_others == 'false' ) $graph_query = 'posts';
409
410 } else {
411 //Else use the settings page option or the 'showpostsby' shortcode option
412
413 //Only show posts by me
414 if ( $show_posts_by == 'me' ) $graph_query = 'posts';
415
416 //Show posts by everyone
417 if ( $show_posts_by == 'others' || $cff_is_group ) $graph_query = 'feed';
418
419 //Show posts ONLY by others
420 if ( $show_posts_by == 'onlyothers' && !$cff_is_group ) {
421 $graph_query = 'feed';
422 $cff_show_only_others = true;
423 }
424
425 }
426
427
428 //Calculate the cache time in seconds
429 if($cff_cache_time_unit == 'minutes') $cff_cache_time_unit = 60;
430 if($cff_cache_time_unit == 'hours') $cff_cache_time_unit = 60*60;
431 if($cff_cache_time_unit == 'days') $cff_cache_time_unit = 60*60*24;
432 $cache_seconds = $cff_cache_time * $cff_cache_time_unit;
433
434 //Get like box vars
435 $cff_likebox_width = $atts[ 'likeboxwidth' ];
436 if ( !isset($cff_likebox_width) || empty($cff_likebox_width) || $cff_likebox_width == '' ) $cff_likebox_width = 300;
437 $cff_like_box_faces = $atts[ 'likeboxfaces' ];
438 if ( !isset($cff_like_box_faces) || empty($cff_like_box_faces) ) $cff_like_box_faces = 'false';
439
440 //Set like box variable
441 $like_box = '<div class="cff-likebox';
442 if ($cff_like_box_outside) $like_box .= ' cff-outside';
443 $like_box .= ($cff_like_box_position == 'top') ? ' top' : ' bottom';
444 $like_box .= '" ' . $cff_likebox_styles . '><script src="http://connect.facebook.net/' . $cff_locale . '/all.js#xfbml=1"></script><fb:like-box href="http://www.facebook.com/' . $page_id . '" show_faces="'.$cff_like_box_faces.'" stream="false" header="false" colorscheme="'. $cff_like_box_colorscheme .'" show_border="'. $cff_like_box_border .'"></fb:like-box></div>';
445 //Don't show like box if it's a group
446 if($cff_is_group) $like_box = '';
447
448
449 //Feed header
450 $cff_show_header = $atts['showheader'];
451 $cff_header_outside = $atts['headeroutside'];
452 $cff_header_text = $atts['headertext'];
453 $cff_header_icon = $atts['headericon'];
454 $cff_header_icon_color = $atts['headericoncolor'];
455 $cff_header_icon_size = $atts['headericonsize'];
456
457 $cff_header = '<h3 class="cff-header';
458 if ($cff_header_outside) $cff_header .= ' cff-outside';
459 $cff_header .= '"' . $cff_header_styles . '>';
460 $cff_header .= '<i class="fa fa-' . $cff_header_icon . '"';
461 if(!empty($cff_header_icon_color) || !empty($cff_header_icon_size)) $cff_header .= ' style="';
462 if(!empty($cff_header_icon_color)) $cff_header .= 'color: #' . $cff_header_icon_color . ';';
463 if(!empty($cff_header_icon_size)) $cff_header .= ' font-size: ' . $cff_header_icon_size . 'px;';
464 if(!empty($cff_header_icon_color) || !empty($cff_header_icon_size))$cff_header .= '"';
465 $cff_header .= '></i>';
466 $cff_header .= $cff_header_text;
467 $cff_header .= '</h3>';
468
469
470 //***START FEED***
471 $cff_content = '';
472
473 //Add the page header to the outside of the top of feed
474 if ($cff_show_header && $cff_header_outside) $cff_content .= $cff_header;
475
476 //Add like box to the outside of the top of feed
477 if ($cff_like_box_position == 'top' && $cff_show_like_box && $cff_like_box_outside) $cff_content .= $like_box;
478
479 //Create CFF container HTML
480 $cff_content .= '<div id="cff" rel="'.$title_limit.'" class="';
481 if( !empty($cff_class) ) $cff_content .= $cff_class . ' ';
482 if ( !empty($cff_feed_height) ) $cff_content .= 'cff-fixed-height ';
483 $cff_content .= '" ' . $cff_feed_styles . '>';
484
485 //Add the page header to the inside of the top of feed
486 if ($cff_show_header && !$cff_header_outside) $cff_content .= $cff_header;
487
488 //Add like box to the inside of the top of feed
489 if ($cff_like_box_position == 'top' && $cff_show_like_box && !$cff_like_box_outside) $cff_content .= $like_box;
490 //Limit var
491 $i = 0;
492
493
494 //ALL POSTS
495 if (!$cff_events_only){
496
497 $cff_posts_json_url = 'https://graph.facebook.com/' . $page_id . '/' . $graph_query . '?access_token=' . $access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale . $cff_ssl;
498
499 //Don't use caching if the cache time is set to zero
500 if ($cff_cache_time != 0){
501 // Get any existing copy of our transient data
502 $transient_name = 'cff_'. $graph_query .'_json_' . $page_id;
503 if ( false === ( $posts_json = get_transient( $transient_name ) ) || $posts_json === null ) {
504 //Get the contents of the Facebook page
505 $posts_json = cff_fetchUrl($cff_posts_json_url);
506 //Cache the JSON
507 set_transient( $transient_name, $posts_json, $cache_seconds );
508 } else {
509 $posts_json = get_transient( $transient_name );
510 }
511 } else {
512 $posts_json = cff_fetchUrl($cff_posts_json_url);
513 }
514
515
516
517 //Interpret data with JSON
518 $FBdata = json_decode($posts_json);
519 //***STARTS POSTS LOOP***
520 foreach ($FBdata->data as $news )
521 {
522 //Explode News and Page ID's into 2 values
523 $PostID = explode("_", $news->id);
524 //Check the post type
525 $cff_post_type = $news->type;
526 if ($cff_post_type == 'link') {
527 isset($news->story) ? $story = $news->story : $story = '';
528 //Check whether it's an event
529 $event_link_check = "facebook.com/events/";
530 $event_link_check = stripos($news->link, $event_link_check);
531 if ( $event_link_check ) $cff_post_type = 'event';
532 }
533 //Should we show this post or not?
534 $cff_show_post = false;
535 switch ($cff_post_type) {
536 case 'link':
537 if ( $cff_show_links_type ) $cff_show_post = true;
538 break;
539 case 'event':
540 if ( $cff_show_event_type ) $cff_show_post = true;
541 break;
542 case 'video':
543 if ( $cff_show_video_type ) $cff_show_post = true;
544 break;
545 case 'swf':
546 if ( $cff_show_video_type ) $cff_show_post = true;
547 break;
548 case 'photo':
549 if ( $cff_show_photos_type ) $cff_show_post = true;
550 break;
551 case 'offer':
552 $cff_show_post = true;
553 break;
554 case 'status':
555 //Check whether it's a status (author comment or like)
556 if ( $cff_show_status_type && !empty($news->message) ) $cff_show_post = true;
557 break;
558 }
559
560
561 //ONLY show posts by others
562 if ( $cff_show_only_others ) {
563 //Get the numeric ID of the page
564 $page_object = cff_fetchUrl('https://graph.facebook.com/' . $page_id);
565 $page_object = json_decode($page_object);
566 $numeric_page_id = $page_object->id;
567
568 //If the post author's ID is the same as the page ID then don't show the post
569 if ( $numeric_page_id == $news->from->id ) $cff_show_post = false;
570 }
571
572
573 //Is it a duplicate post?
574 if (!isset($prev_post_message)) $prev_post_message = '';
575 if (!isset($prev_post_link)) $prev_post_link = '';
576 if (!isset($prev_post_description)) $prev_post_description = '';
577 isset($news->message) ? $pm = $news->message : $pm = '';
578 isset($news->link) ? $pl = $news->link : $pl = '';
579 isset($news->description) ? $pd = $news->description : $pd = '';
580
581 if ( ($prev_post_message == $pm) && ($prev_post_link == $pl) && ($prev_post_description == $pd) ) $cff_show_post = false;
582
583 //Check post type and display post if selected
584 if ( $cff_show_post ) {
585 //If it isn't then create the post
586 //Only create posts for the amount of posts specified
587 if ( $i == $show_posts ) break;
588 $i++;
589 //********************************//
590 //***COMPILE SECTION VARIABLES***//
591 //********************************//
592 //Set the post link
593 isset($news->link) ? $link = $news->link : $link = '';
594 //Is it a shared album?
595 $shared_album_string = 'shared an album:';
596 isset($news->story) ? $story = $news->story : $story = '';
597 $shared_album = stripos($story, $shared_album_string);
598 if ( $shared_album ) {
599 $link = str_replace('photo.php?','media/set/?',$link);
600 }
601
602 //Is it an album?
603 $cff_album = false;
604 $album_string = 'relevant_count=';
605 $relevant_count = stripos($link, $album_string);
606
607 if ( $relevant_count ) {
608 //If relevant_count is larger than 1 then there are multiple photos
609 $relevant_count = explode('relevant_count=', $link);
610 $num_photos = intval($relevant_count[1]);
611 if ( $num_photos > 1 ) {
612 $cff_album = true;
613
614 //Link to the album instead of the photo
615 $album_link = str_replace('photo.php?','media/set/?',$link);
616 $link = "https://www.facebook.com/" . $page_id . "/posts/" . $PostID[1];
617 }
618 }
619
620 //If there's no link provided then link to either the Facebook page or the individual status
621 if (empty($news->link)) {
622 if ($cff_link_to_timeline == true){
623 //Link to page
624 $link = 'http://facebook.com/' . $page_id;
625 } else {
626 //Link to status
627 $link = "https://www.facebook.com/" . $page_id . "/posts/" . $PostID[1];
628 }
629 }
630
631 //POST AUTHOR
632 $cff_author = '<a class="cff-author" href="http://facebook.com/' . $news->from->id . '" '.$target.' title="'.$news->from->name.' on Facebook">';
633 $cff_author .= '<img src="http://graph.facebook.com/' . $news->from->id . '/picture" width=50 height=50>';
634 $cff_author .= '<span class="cff-page-name">'.$news->from->name.'</span>';
635 $cff_author .= '</a>';
636
637 //POST TEXT
638 $cff_translate_photos_text = $atts['photostext'];
639 if (!isset($cff_translate_photos_text) || empty($cff_translate_photos_text)) $cff_translate_photos_text = 'photos';
640 $cff_post_text = '<' . $cff_title_format . ' class="cff-post-text" ' . $cff_title_styles . '>';
641 //__ shared __'s photo
642 // if ($news->type == 'photo' && !empty($news->story) ) $cff_post_text .= '<span class="cff-byline" '.$cff_body_styles.'>' . $news->story . '</span>';
643 // $cff_post_text = '<div class="cff-post-text" ' . $cff_title_styles . '>';
644 $cff_post_text .= '<span class="cff-text">';
645 if ($cff_title_link == 'true') $cff_post_text .= '<a class="cff-post-text-link" href="'.$link.'" '.$target.'>';
646 if (!empty($news->story)) $post_text = $news->story;
647 if (!empty($news->message)) $post_text = $news->message;
648 if (!empty($news->name) && empty($news->story) && empty($news->message)) $post_text = $news->name;
649 if ($cff_album) {
650 if (!empty($news->name)) $post_text = $news->name;
651 if (!empty($news->message) && empty($news->name)) $post_text = $news->message;
652 $post_text .= ' (' . $num_photos . ' '.$cff_translate_photos_text.')';
653 }
654
655
656 //If the text is wrapped in a link then don't hyperlink any text within
657 if ($cff_title_link) {
658 //Wrap links in a span so we can break the text if it's too long
659 $cff_post_text .= cff_wrap_span( htmlspecialchars($post_text) ) . ' ';
660 } else {
661 $cff_post_text .= cff_make_clickable( htmlspecialchars($post_text) ) . ' ';
662 }
663
664 if ($cff_title_link) $cff_post_text .= '</a>';
665 $cff_post_text .= '</span>';
666 //'See More' link
667 $cff_post_text .= '<span class="cff-expand">... <a href="#"><span class="cff-more">' . $cff_see_more_text . '</span><span class="cff-less">' . $cff_see_less_text . '</span></a></span>';
668 $cff_post_text .= '</' . $cff_title_format . '>';
669
670 //DESCRIPTION
671 $cff_description = '';
672 //Use the description if it's available and the post type isn't set to offer (offer description isn't useful)
673 if ( ( !empty($news->description) || !empty($news->caption) ) && $cff_post_type != 'offer') {
674
675 isset($news->description) ? $description_text = $news->description : $description_text = '';
676 if (!isset($description_text)) $description_text = $news->caption;
677
678 if (!empty($body_limit)) {
679 if (strlen($description_text) > $body_limit) $description_text = substr($description_text, 0, $body_limit) . '...';
680 }
681 $cff_description .= '<p class="cff-post-desc" '.$cff_body_styles.'><span>' . cff_make_clickable( htmlspecialchars($description_text) ) . '</span></p>';
682
683 //If the post text and description/caption are the same then don't show the description
684 if($post_text == $description_text) $cff_description = '';
685
686 }
687
688 //LINK
689 $cff_shared_link = '';
690 //Display shared link
691 if ($news->type == 'link') {
692 $cff_shared_link .= '<div class="cff-shared-link">';
693
694 //Display link name and description
695 if (!empty($news->description)) {
696 $cff_shared_link .= '<div class="cff-text-link ';
697 $cff_shared_link .= 'cff-no-image';
698 $cff_shared_link .= '"><a class="cff-link-title" href="'.$link.'" '.$target.'>'. '<b>' . $news->name . '</b></a>';
699 if(!empty($news->caption)) $cff_shared_link .= '<p class="cff-link-caption">'.$news->caption.'</p>';
700 $cff_shared_link .= $cff_description;
701 $cff_shared_link .= '</div>';
702 }
703
704 $cff_shared_link .= '</div>';
705 }
706
707 //DATE
708 $cff_date_formatting = $atts[ 'dateformat' ];
709 $cff_date_custom = $atts[ 'datecustom' ];
710 $cff_date = '<p class="cff-date" '.$cff_date_styles.'>'. $cff_date_before . ' ' . cff_getdate(strtotime($news->created_time), $cff_date_formatting, $cff_date_custom) . ' ' . $cff_date_after . '</p>';
711 //EVENT
712 $cff_event = '';
713 if ($cff_show_event_title || $cff_show_event_details) {
714 //Check for media
715 if ($cff_post_type == 'event') {
716
717 //Get the event id from the event URL. eg: http://www.facebook.com/events/123451234512345/
718 $event_url = parse_url($link);
719 $url_parts = explode('/', $event_url['path']);
720 //Get the id from the parts
721 $eventID = $url_parts[count($url_parts)-2];
722
723 //Get the contents of the event using the WP HTTP API
724 $event_json = cff_fetchUrl('https://graph.facebook.com/'.$eventID.'?access_token=' . $access_token . $cff_ssl);
725 //Interpret data with JSON
726 $event_object = json_decode($event_json);
727 //Event date
728 isset( $event_object->start_time ) ? $event_time = $event_object->start_time : $event_time = '';
729 //If timezone migration is enabled then remove last 5 characters
730 if ( strlen($event_time) == 24 ) $event_time = substr($event_time, 0, -5);
731 if (!empty($event_time)) $cff_event_date = '<p class="cff-date" '.$cff_event_date_styles.'>' . cff_eventdate(strtotime($event_time), $cff_event_date_formatting, $cff_event_date_custom) . '</p>';
732 //EVENT
733 //Display the event details
734 $cff_event .= '<div class="cff-details">';
735 //show event date above title
736 if ($cff_event_date_position == 'above') $cff_event .= $cff_event_date;
737 //Show event title
738 if ($cff_show_event_title && !empty($event_object->name)) {
739 if ($cff_event_title_link) $cff_event .= '<a href="'.$link.'">';
740 $cff_event .= '<' . $cff_event_title_format . ' ' . $cff_event_title_styles . '>' . $event_object->name . '</' . $cff_event_title_format . '>';
741 if ($cff_event_title_link) $cff_event .= '</a>';
742 }
743 //show event date below title
744 if ($cff_event_date_position !== 'above') $cff_event .= $cff_event_date;
745 //Show event details
746 if ($cff_show_event_details){
747 //Location
748 if (!empty($event_object->location)) $cff_event .= '<p class="cff-where" ' . $cff_event_details_styles . '>' . $event_object->location . '</p>';
749 //Description
750 if (!empty($event_object->description)){
751 $description = $event_object->description;
752 if (!empty($body_limit)) {
753 if (strlen($description) > $body_limit) $description = substr($description, 0, $body_limit) . '...';
754 }
755 $cff_event .= '<p class="cff-info" ' . $cff_event_details_styles . '>' . cff_make_clickable($description) . '</p>';
756 }
757 }
758 $cff_event .= '</div>';
759
760 }
761 }
762
763 /* VIDEO */
764 $cff_is_video_embed = false;
765 $cff_media = '';
766 if ($news->type == 'video') {
767 $cff_is_video_embed = true;
768 //Add the name to the description if it's a video embed
769 if($cff_is_video_embed) {
770 isset($news->name) ? $video_name = $news->name : $video_name = $link;
771 isset($news->description) ? $description_text = $news->description : $description_text = '';
772 $cff_description = '<div class="cff-desc-wrap ';
773 if (empty($picture)) $cff_description .= 'cff-no-image';
774 $cff_description .= '"><a class="cff-link-title" href="'.$link.'" '.$target.'>'. '<b>' . $video_name . '</b></a>';
775 $cff_description .= '<p class="cff-post-desc" '.$cff_body_styles.'><span>' . cff_make_clickable( htmlspecialchars($description_text) ) . '</span></p></div>';
776 }
777 }
778
779
780 //Display the link to the Facebook post or external link
781 $cff_link = '';
782 //Default link
783 $cff_viewpost_class = 'cff-viewpost-facebook';
784 if ($cff_facebook_link_text == '') $cff_facebook_link_text = 'View on Facebook';
785 $link_text = $cff_facebook_link_text;
786
787 //Link to the Facebook post if it's a link or a video
788 if($cff_post_type == 'link' || $cff_post_type == 'video') $link = "https://www.facebook.com/" . $page_id . "/posts/" . $PostID[1];
789
790 if ($cff_post_type == 'offer') $link_text = 'View Offer';
791 $cff_link = '<a class="' . $cff_viewpost_class . '" href="' . $link . '" title="' . $link_text . '" ' . $target . ' ' . $cff_link_styles . '>' . $link_text . '</a>';
792
793
794 //**************************//
795 //***CREATE THE POST HTML***//
796 //**************************//
797 //Start the container
798 $cff_content .= '<div class="cff-item ';
799 if ($cff_post_type == 'link') $cff_content .= 'cff-link-item';
800 if ($cff_post_type == 'event') $cff_content .= 'cff-timeline-event';
801 if ($cff_post_type == 'photo') $cff_content .= 'cff-photo-post';
802 if ($cff_post_type == 'video') $cff_content .= 'cff-video-post';
803 if ($cff_post_type == 'swf') $cff_content .= 'cff-swf-post';
804 if ($cff_post_type == 'status') $cff_content .= 'cff-status-post';
805 if ($cff_post_type == 'offer') $cff_content .= 'cff-offer-post';
806 if ($cff_album) $cff_content .= ' cff-album';
807 $cff_content .= '" id="'. $news->id .'" ' . $cff_item_styles . '>';
808
809 //POST AUTHOR
810 if($cff_show_author) $cff_content .= $cff_author;
811 //DATE ABOVE
812 if ($cff_show_date && $cff_date_position == 'above') $cff_content .= $cff_date;
813 //POST TEXT
814 if($cff_show_text) $cff_content .= $cff_post_text;
815 //DESCRIPTION
816 if($cff_show_desc && $cff_post_type != 'offer' && $cff_post_type != 'link') $cff_content .= $cff_description;
817 //LINK
818 if($cff_show_shared_links) $cff_content .= $cff_shared_link;
819 //DATE BELOW
820 if ($cff_show_date && $cff_date_position == 'below') $cff_content .= $cff_date;
821 //EVENT
822 if($cff_show_event_title || $cff_show_event_details) $cff_content .= $cff_event;
823 //VIEW ON FACEBOOK LINK
824 if($cff_show_link) $cff_content .= $cff_link;
825
826 //End the post item
827 $cff_content .= '</div><div class="cff-clear"></div>';
828 } // End post type check
829
830 if (isset($news->message)) $prev_post_message = $news->message;
831 if (isset($news->link)) $prev_post_link = $news->link;
832 if (isset($news->description)) $prev_post_description = $news->description;
833
834 } // End the loop
835 } // End ALL POSTS
836 //Load more posts
837 // $cff_content .= '<button class="loadmore">Load More Posts</button>';
838 //Add the Like Box inside
839 if ($cff_like_box_position == 'bottom' && $cff_show_like_box && !$cff_like_box_outside) $cff_content .= $like_box;
840 //End the feed
841 $cff_content .= '</div><div class="cff-clear"></div>';
842 //Add the Like Box outside
843 if ($cff_like_box_position == 'bottom' && $cff_show_like_box && $cff_like_box_outside) $cff_content .= $like_box;
844 //Return our feed HTML to display
845 return $cff_content;
846 }
847 //Get JSON object of feed data
848 function cff_fetchUrl($url){
849 //Can we use cURL?
850 if(is_callable('curl_init')){
851 $ch = curl_init();
852 curl_setopt($ch, CURLOPT_URL, $url);
853 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
854 curl_setopt($ch, CURLOPT_TIMEOUT, 20);
855 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
856 $feedData = curl_exec($ch);
857 curl_close($ch);
858 //If not then use file_get_contents
859 } elseif ( ini_get('allow_url_fopen') == 1 || ini_get('allow_url_fopen') === TRUE ) {
860 $feedData = @file_get_contents($url);
861 //Or else use the WP HTTP API
862 } else {
863 if( !class_exists( 'WP_Http' ) ) include_once( ABSPATH . WPINC. '/class-http.php' );
864 $request = new WP_Http;
865 $result = $request->request($url);
866 $feedData = $result['body'];
867 }
868
869 return $feedData;
870 }
871 //***FUNCTIONS***
872 //Make links in text clickable
873 function cff_make_clickable($text) {
874 $pattern = '#\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))#';
875 return preg_replace_callback($pattern, 'cff_auto_link_text_callback', $text);
876 }
877 function cff_auto_link_text_callback($matches) {
878 $max_url_length = 50;
879 $max_depth_if_over_length = 2;
880 $ellipsis = '&hellip;';
881 $target = 'target="_blank"';
882 $url_full = $matches[0];
883 $url_short = '';
884 if (strlen($url_full) > $max_url_length) {
885 $parts = parse_url($url_full);
886 $url_short = $parts['scheme'] . '://' . preg_replace('/^www\./', '', $parts['host']) . '/';
887 $path_components = explode('/', trim($parts['path'], '/'));
888 foreach ($path_components as $dir) {
889 $url_string_components[] = $dir . '/';
890 }
891 if (!empty($parts['query'])) {
892 $url_string_components[] = '?' . $parts['query'];
893 }
894 if (!empty($parts['fragment'])) {
895 $url_string_components[] = '#' . $parts['fragment'];
896 }
897 for ($k = 0; $k < count($url_string_components); $k++) {
898 $curr_component = $url_string_components[$k];
899 if ($k >= $max_depth_if_over_length || strlen($url_short) + strlen($curr_component) > $max_url_length) {
900 if ($k == 0 && strlen($url_short) < $max_url_length) {
901 // Always show a portion of first directory
902 $url_short .= substr($curr_component, 0, $max_url_length - strlen($url_short));
903 }
904 $url_short .= $ellipsis;
905 break;
906 }
907 $url_short .= $curr_component;
908 }
909 } else {
910 $url_short = $url_full;
911 }
912 if( substr( $url_full, 0, 4 ) !== "http" ) $url_full = 'http://' . $url_full;
913 return "<a class='cff-break-word' rel=\"nofollow\" href=\"$url_full\" " . $target . ">$url_full</a>";
914 }
915 //Make links into span instead when the post text is made clickable
916 function cff_wrap_span($text) {
917 $pattern = '#\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))#';
918 return preg_replace_callback($pattern, 'cff_wrap_span_callback', $text);
919 }
920 function cff_wrap_span_callback($matches) {
921 $max_url_length = 50;
922 $max_depth_if_over_length = 2;
923 $ellipsis = '&hellip;';
924 $target = 'target="_blank"';
925 $url_full = $matches[0];
926 $url_short = '';
927 if (strlen($url_full) > $max_url_length) {
928 $parts = parse_url($url_full);
929 $url_short = $parts['scheme'] . '://' . preg_replace('/^www\./', '', $parts['host']) . '/';
930 $path_components = explode('/', trim($parts['path'], '/'));
931 foreach ($path_components as $dir) {
932 $url_string_components[] = $dir . '/';
933 }
934 if (!empty($parts['query'])) {
935 $url_string_components[] = '?' . $parts['query'];
936 }
937 if (!empty($parts['fragment'])) {
938 $url_string_components[] = '#' . $parts['fragment'];
939 }
940 for ($k = 0; $k < count($url_string_components); $k++) {
941 $curr_component = $url_string_components[$k];
942 if ($k >= $max_depth_if_over_length || strlen($url_short) + strlen($curr_component) > $max_url_length) {
943 if ($k == 0 && strlen($url_short) < $max_url_length) {
944 // Always show a portion of first directory
945 $url_short .= substr($curr_component, 0, $max_url_length - strlen($url_short));
946 }
947 $url_short .= $ellipsis;
948 break;
949 }
950 $url_short .= $curr_component;
951 }
952 } else {
953 $url_short = $url_full;
954 }
955 return "<span class='cff-break-word'>$url_short</span>";
956 }
957 //2013-04-28T21:06:56+0000
958 //Time stamp function - used for posts
959 function cff_getdate($original, $date_format, $custom_date) {
960 switch ($date_format) {
961
962 case '2':
963 $print = date_i18n('F jS, g:i a', $original);
964 break;
965 case '3':
966 $print = date_i18n('F jS', $original);
967 break;
968 case '4':
969 $print = date_i18n('D F jS', $original);
970 break;
971 case '5':
972 $print = date_i18n('l F jS', $original);
973 break;
974 case '6':
975 $print = date_i18n('D M jS, Y', $original);
976 break;
977 case '7':
978 $print = date_i18n('l F jS, Y', $original);
979 break;
980 case '8':
981 $print = date_i18n('l F jS, Y - g:i a', $original);
982 break;
983 case '9':
984 $print = date_i18n("l M jS, 'y", $original);
985 break;
986 case '10':
987 $print = date_i18n('m.d.y', $original);
988 break;
989 case '11':
990 $print = date_i18n('m/d/y', $original);
991 break;
992 case '12':
993 $print = date_i18n('d.m.y', $original);
994 break;
995 case '13':
996 $print = date_i18n('d/m/y', $original);
997 break;
998 default:
999
1000 $options = get_option('cff_style_settings');
1001
1002 $cff_second = isset($options['cff_translate_second']) ? $options['cff_translate_second'] : '';
1003 if ( empty($cff_second) ) $cff_second = 'second';
1004
1005 $cff_seconds = isset($options['cff_translate_seconds']) ? $options['cff_translate_seconds'] : '';
1006 if ( empty($cff_seconds) ) $cff_seconds = 'seconds';
1007
1008 $cff_minute = isset($options['cff_translate_minute']) ? $options['cff_translate_minute'] : '';
1009 if ( empty($cff_minute) ) $cff_minute = 'minute';
1010
1011 $cff_minutes = isset($options['cff_translate_minutes']) ? $options['cff_translate_minutes'] : '';
1012 if ( empty($cff_minutes) ) $cff_minutes = 'minutes';
1013
1014 $cff_hour = isset($options['cff_translate_hour']) ? $options['cff_translate_hour'] : '';
1015 if ( empty($cff_hour) ) $cff_hour = 'hour';
1016
1017 $cff_hours = isset($options['cff_translate_hours']) ? $options['cff_translate_hours'] : '';
1018 if ( empty($cff_hours) ) $cff_hours = 'hours';
1019
1020 $cff_day = isset($options['cff_translate_day']) ? $options['cff_translate_day'] : '';
1021 if ( empty($cff_day) ) $cff_day = 'day';
1022
1023 $cff_days = isset($options['cff_translate_days']) ? $options['cff_translate_days'] : '';
1024 if ( empty($cff_days) ) $cff_days = 'days';
1025
1026 $cff_week = isset($options['cff_translate_week']) ? $options['cff_translate_week'] : '';
1027 if ( empty($cff_week) ) $cff_week = 'week';
1028
1029 $cff_weeks = isset($options['cff_translate_weeks']) ? $options['cff_translate_weeks'] : '';
1030 if ( empty($cff_weeks) ) $cff_weeks = 'weeks';
1031
1032 $cff_month = isset($options['cff_translate_month']) ? $options['cff_translate_month'] : '';
1033 if ( empty($cff_month) ) $cff_month = 'month';
1034
1035 $cff_months = isset($options['cff_translate_months']) ? $options['cff_translate_months'] : '';
1036 if ( empty($cff_months) ) $cff_months = 'months';
1037
1038 $cff_year = isset($options['cff_translate_year']) ? $options['cff_translate_year'] : '';
1039 if ( empty($cff_year) ) $cff_year = 'year';
1040
1041 $cff_years = isset($options['cff_translate_years']) ? $options['cff_translate_years'] : '';
1042 if ( empty($cff_years) ) $cff_years = 'years';
1043
1044 $cff_ago = isset($options['cff_translate_ago']) ? $options['cff_translate_ago'] : '';
1045 if ( empty($cff_ago) ) $cff_ago = 'ago';
1046
1047
1048 $periods = array($cff_second, $cff_minute, $cff_hour, $cff_day, $cff_week, $cff_month, $cff_year, "decade");
1049 $periods_plural = array($cff_seconds, $cff_minutes, $cff_hours, $cff_days, $cff_weeks, $cff_months, $cff_years, "decade");
1050
1051 $lengths = array("60","60","24","7","4.35","12","10");
1052 $now = time();
1053
1054 // is it future date or past date
1055 if($now > $original) {
1056 $difference = $now - $original;
1057 $tense = $cff_ago;
1058 } else {
1059 $difference = $original - $now;
1060 $tense = $cff_ago;
1061 }
1062 for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
1063 $difference /= $lengths[$j];
1064 }
1065
1066 $difference = round($difference);
1067
1068 if($difference != 1) {
1069 $periods[$j] = $periods_plural[$j];
1070 }
1071 $print = "$difference $periods[$j] {$tense}";
1072
1073 break;
1074
1075 }
1076 if ( !empty($custom_date) ){
1077 $print = date_i18n($custom_date, $original);
1078 }
1079
1080 return $print;
1081 }
1082 function cff_eventdate($original, $date_format, $custom_date) {
1083 switch ($date_format) {
1084
1085 case '2':
1086 $print = date_i18n('F jS, g:ia', $original);
1087 break;
1088 case '3':
1089 $print = date_i18n('g:ia - F jS', $original);
1090 break;
1091 case '4':
1092 $print = date_i18n('g:ia, F jS', $original);
1093 break;
1094 case '5':
1095 $print = date_i18n('l F jS - g:ia', $original);
1096 break;
1097 case '6':
1098 $print = date_i18n('D M jS, Y, g:iA', $original);
1099 break;
1100 case '7':
1101 $print = date_i18n('l F jS, Y, g:iA', $original);
1102 break;
1103 case '8':
1104 $print = date_i18n('l F jS, Y - g:ia', $original);
1105 break;
1106 case '9':
1107 $print = date_i18n("l M jS, 'y", $original);
1108 break;
1109 case '10':
1110 $print = date_i18n('m.d.y - g:iA', $original);
1111 break;
1112 case '11':
1113 $print = date_i18n('m/d/y, g:ia', $original);
1114 break;
1115 case '12':
1116 $print = date_i18n('d.m.y - g:iA', $original);
1117 break;
1118 case '13':
1119 $print = date_i18n('d/m/y, g:ia', $original);
1120 break;
1121 default:
1122 $print = date_i18n('F j, Y, g:ia', $original);
1123 break;
1124 }
1125 if ( !empty($custom_date) ){
1126 $print = date_i18n($custom_date, $original);
1127 }
1128 return $print;
1129 }
1130 //Time stamp function - used for comments
1131 function cff_timesince($original) {
1132
1133 $options = get_option('cff_style_settings');
1134
1135 $cff_second = isset($options['cff_translate_second']) ? $options['cff_translate_second'] : '';
1136 if ( empty($cff_second) ) $cff_second = 'second';
1137
1138 $cff_seconds = isset($options['cff_translate_seconds']) ? $options['cff_translate_seconds'] : '';
1139 if ( empty($cff_seconds) ) $cff_seconds = 'seconds';
1140
1141 $cff_minute = isset($options['cff_translate_minute']) ? $options['cff_translate_minute'] : '';
1142 if ( empty($cff_minute) ) $cff_minute = 'minute';
1143
1144 $cff_minutes = isset($options['cff_translate_minutes']) ? $options['cff_translate_minutes'] : '';
1145 if ( empty($cff_minutes) ) $cff_minutes = 'minutes';
1146
1147 $cff_hour = isset($options['cff_translate_hour']) ? $options['cff_translate_hour'] : '';
1148 if ( empty($cff_hour) ) $cff_hour = 'hour';
1149
1150 $cff_hours = isset($options['cff_translate_hours']) ? $options['cff_translate_hours'] : '';
1151 if ( empty($cff_hours) ) $cff_hours = 'hours';
1152
1153 $cff_day = isset($options['cff_translate_day']) ? $options['cff_translate_day'] : '';
1154 if ( empty($cff_day) ) $cff_day = 'day';
1155
1156 $cff_days = isset($options['cff_translate_days']) ? $options['cff_translate_days'] : '';
1157 if ( empty($cff_days) ) $cff_days = 'days';
1158
1159 $cff_week = isset($options['cff_translate_week']) ? $options['cff_translate_week'] : '';
1160 if ( empty($cff_week) ) $cff_week = 'week';
1161
1162 $cff_weeks = isset($options['cff_translate_weeks']) ? $options['cff_translate_weeks'] : '';
1163 if ( empty($cff_weeks) ) $cff_weeks = 'weeks';
1164
1165 $cff_month = isset($options['cff_translate_month']) ? $options['cff_translate_month'] : '';
1166 if ( empty($cff_month) ) $cff_month = 'month';
1167
1168 $cff_months = isset($options['cff_translate_months']) ? $options['cff_translate_months'] : '';
1169 if ( empty($cff_months) ) $cff_months = 'months';
1170
1171 $cff_year = isset($options['cff_translate_year']) ? $options['cff_translate_year'] : '';
1172 if ( empty($cff_year) ) $cff_year = 'year';
1173
1174 $cff_years = isset($options['cff_translate_years']) ? $options['cff_translate_years'] : '';
1175 if ( empty($cff_years) ) $cff_years = 'years';
1176
1177 $cff_ago = isset($options['cff_translate_ago']) ? $options['cff_translate_ago'] : '';
1178 if ( empty($cff_ago) ) $cff_ago = 'ago';
1179
1180
1181 $periods = array($cff_second, $cff_minute, $cff_hour, $cff_day, $cff_week, $cff_month, $cff_year, "decade");
1182 $periods_plural = array($cff_seconds, $cff_minutes, $cff_hours, $cff_days, $cff_weeks, $cff_months, $cff_years, "decade");
1183
1184 $lengths = array("60","60","24","7","4.35","12","10");
1185 $now = time();
1186
1187 // is it future date or past date
1188 if($now > $original) {
1189 $difference = $now - $original;
1190 $tense = $cff_ago;
1191 } else {
1192 $difference = $original - $now;
1193 $tense = $cff_ago;
1194 }
1195 for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
1196 $difference /= $lengths[$j];
1197 }
1198
1199 $difference = round($difference);
1200
1201 if($difference != 1) {
1202 $periods[$j] = $periods_plural[$j];
1203 }
1204 return "$difference $periods[$j] {$tense}";
1205
1206 }
1207 //Use custom stripos function if it's not available (only available in PHP 5+)
1208 if(!is_callable('stripos')){
1209 function stripos($haystack, $needle){
1210 return strpos($haystack, stristr( $haystack, $needle ));
1211 }
1212 }
1213
1214 // remove_filter( 'the_content', 'wpautop' );
1215 // add_filter( 'the_content', 'wpautop', 99 );
1216
1217
1218 //Allows shortcodes in theme
1219 add_filter('widget_text', 'do_shortcode');
1220
1221 //Enqueue stylesheet
1222 add_action( 'wp_enqueue_scripts', 'cff_add_my_stylesheet' );
1223 function cff_add_my_stylesheet() {
1224 // Respects SSL, Style.css is relative to the current file
1225 wp_register_style( 'cff', plugins_url('css/cff-style.css?5', __FILE__) );
1226 wp_enqueue_style( 'cff' );
1227 wp_enqueue_style( 'cff-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css', array(), '4.0.3' );
1228 }
1229 //Enqueue scripts
1230 add_action( 'wp_enqueue_scripts', 'cff_scripts_method' );
1231 function cff_scripts_method() {
1232 //Register the script to make it available
1233 wp_register_script( 'cffscripts', plugins_url( '/js/cff-scripts.js?5' , __FILE__ ), array('jquery'), '1.8', true );
1234 //Enqueue it to load it onto the page
1235 wp_enqueue_script('cffscripts');
1236 }
1237
1238 function cff_activate() {
1239 $options = get_option('cff_style_settings');
1240 $options[ 'cff_show_links_type' ] = true;
1241 $options[ 'cff_show_event_type' ] = true;
1242 $options[ 'cff_show_video_type' ] = true;
1243 $options[ 'cff_show_photos_type' ] = true;
1244 $options[ 'cff_show_status_type' ] = true;
1245 // Show all parts of the feed by default on activation
1246 $options[ 'cff_show_author' ] = true;
1247 $options[ 'cff_show_text' ] = true;
1248 $options[ 'cff_show_desc' ] = true;
1249 $options[ 'cff_show_shared_links' ] = true;
1250 $options[ 'cff_show_date' ] = true;
1251 $options[ 'cff_show_media' ] = true;
1252 $options[ 'cff_show_event_title' ] = true;
1253 $options[ 'cff_show_event_details' ] = true;
1254 $options[ 'cff_show_meta' ] = true;
1255 $options[ 'cff_show_link' ] = true;
1256 $options[ 'cff_show_like_box' ] = true;
1257 update_option( 'cff_style_settings', $options );
1258 }
1259 register_activation_hook( __FILE__, 'cff_activate' );
1260 //Uninstall
1261 function cff_uninstall()
1262 {
1263 if ( ! current_user_can( 'activate_plugins' ) )
1264 return;
1265 //Settings
1266 delete_option( 'cff_access_token' );
1267 delete_option( 'cff_page_id' );
1268 delete_option( 'cff_num_show' );
1269 delete_option( 'cff_post_limit' );
1270 delete_option( 'cff_show_others' );
1271 delete_option('cff_cache_time');
1272 delete_option('cff_cache_time_unit');
1273 delete_option( 'cff_locale' );
1274 //Style & Layout
1275 delete_option( 'cff_title_length' );
1276 delete_option( 'cff_body_length' );
1277 delete_option('cff_style_settings');
1278 }
1279 register_uninstall_hook( __FILE__, 'cff_uninstall' );
1280 add_action( 'wp_head', 'cff_custom_css' );
1281 function cff_custom_css() {
1282 $options = get_option('cff_style_settings');
1283 isset($options[ 'cff_custom_css' ]) ? $cff_custom_css = $options[ 'cff_custom_css' ] : $cff_custom_css = '';
1284 echo "\r\n";
1285 echo '<!-- Custom Facebook Feed Custom CSS -->';
1286 echo "\r\n";
1287 echo '<style type="text/css">';
1288 echo "\r\n";
1289 echo $cff_custom_css;
1290 echo "\r\n";
1291 echo '</style>';
1292 echo "\r\n";
1293 }
1294 add_action( 'wp_footer', 'cff_js' );
1295 function cff_js() {
1296 $options = get_option('cff_style_settings');
1297 $cff_custom_js = isset($options[ 'cff_custom_js' ]) ? $options[ 'cff_custom_js' ] : '';
1298
1299 echo "\r\n";
1300 echo '<!-- Custom Facebook Feed JS -->';
1301 echo "\r\n";
1302 echo '<script type="text/javascript">';
1303 echo "\r\n";
1304 echo "jQuery( document ).ready(function($) {";
1305 echo "\r\n";
1306 echo stripslashes($cff_custom_js);
1307 echo "\r\n";
1308 echo "});";
1309 echo "\r\n";
1310 echo '</script>';
1311 echo "\r\n";
1312 }
1313
1314 //Comment out the line below to view errors
1315 error_reporting(0);
1316 ?>