PluginProbe ʕ •ᴥ•ʔ
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress / 1.6.4
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress v1.6.4
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
1000 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.6.4
7 Author: Smash Balloon
8 Author URI: http://smashballoon.com/
9 License: GPLv2 or later
10 */
11 /*
12 Copyright 2013 Smash Balloon (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 // Add shortcodes
28 add_shortcode('custom-facebook-feed', 'display_cff');
29 function display_cff($atts) {
30
31 //Style options
32 $options = get_option('cff_style_settings');
33 //Create the types string to set as shortcode default
34 if($options[ 'cff_show_links_type' ]) $type_string .= 'links,';
35 if($options[ 'cff_show_event_type' ]) $type_string .= 'events,';
36 if($options[ 'cff_show_video_type' ]) $type_string .= 'videos,';
37 if($options[ 'cff_show_photos_type' ]) $type_string .= 'photos,';
38 if($options[ 'cff_show_status_type' ]) $type_string .= 'statuses,';
39 //Create the types string to set as shortcode default
40 if($options[ 'cff_show_text' ]) $include_string .= 'text,';
41 if($options[ 'cff_show_desc' ]) $include_string .= 'desc,';
42 if($options[ 'cff_show_shared_links' ]) $include_string .= 'sharedlinks,';
43 if($options[ 'cff_show_date' ]) $include_string .= 'date,';
44 if($options[ 'cff_show_media' ]) $include_string .= 'media,';
45 if($options[ 'cff_show_event_title' ]) $include_string .= 'eventtitle,';
46 if($options[ 'cff_show_event_details' ]) $include_string .= 'eventdetails,';
47 if($options[ 'cff_show_meta' ]) $include_string .= 'social,';
48 if($options[ 'cff_show_link' ]) $include_string .= 'link,';
49 if($options[ 'cff_show_like_box' ]) $include_string .= 'likebox,';
50 //Pass in shortcode attrbutes
51 $atts = shortcode_atts(
52 array(
53 'id' => get_option('cff_page_id'),
54 'num' => get_option('cff_num_show'),
55 'limit' => get_option('cff_post_limit'),
56 'others' => get_option('cff_show_others'),
57 'cachetime' => get_option('cff_cache_time'),
58 'cacheunit' => get_option('cff_cache_time_unit'),
59 'locale' => get_option('cff_locale'),
60 'width' => $options[ 'cff_feed_width' ],
61 'height' => $options[ 'cff_feed_height' ],
62 'padding' => $options[ 'cff_feed_padding' ],
63 'bgcolor' => $options[ 'cff_bg_color' ],
64 'showauthor' => $options[ 'cff_show_author' ],
65 'class' => $options[ 'cff_class' ],
66 'layout' => $options[ 'cff_preset_layout' ],
67 'type' => $type_string,
68 'include' => $include_string,
69 //Typography
70 'seemoretext' => $options[ 'cff_see_more_text' ],
71 'seelesstext' => $options[ 'cff_see_less_text' ],
72 'textformat' => $options[ 'cff_title_format' ],
73 'textsize' => $options[ 'cff_title_size' ],
74 'textweight' => $options[ 'cff_title_weight' ],
75 'textcolor' => $options[ 'cff_title_color' ],
76 'textlink' => $options[ 'cff_title_link' ],
77 'descsize' => $options[ 'cff_body_size' ],
78 'descweight' => $options[ 'cff_body_weight' ],
79 'desccolor' => $options[ 'cff_body_color' ],
80 //Event title
81 'eventtitleformat' => $options[ 'cff_event_title_format' ],
82 'eventtitlesize' => $options[ 'cff_event_title_size' ],
83 'eventtitleweight' => $options[ 'cff_event_title_weight' ],
84 'eventtitlecolor' => $options[ 'cff_event_title_color' ],
85 'eventtitlelink' => $options[ 'cff_event_title_link' ],
86 //Event date
87 'eventdatesize' => $options[ 'cff_event_date_size' ],
88 'eventdateweight' => $options[ 'cff_event_date_weight' ],
89 'eventdatecolor' => $options[ 'cff_event_date_color' ],
90 'eventdatepos' => $options[ 'cff_event_date_position' ],
91 'eventdateformat' => $options[ 'cff_event_date_formatting' ],
92 'eventdatecustom' => $options[ 'cff_event_date_custom' ],
93 //Event details
94 'eventdetailssize' => $options[ 'cff_event_details_size' ],
95 'eventdetailsweight' => $options[ 'cff_event_details_weight' ],
96 'eventdetailscolor' => $options[ 'cff_event_details_color' ],
97 //Date
98 'datepos' => $options[ 'cff_date_position' ],
99 'datesize' => $options[ 'cff_date_size' ],
100 'dateweight' => $options[ 'cff_date_weight' ],
101 'datecolor' => $options[ 'cff_date_color' ],
102 'dateformat' => $options[ 'cff_date_formatting' ],
103 'datecustom' => $options[ 'cff_date_custom' ],
104 'linksize' => $options[ 'cff_link_size' ],
105 'linkweight' => $options[ 'cff_link_weight' ],
106 'linkcolor' => $options[ 'cff_link_color' ],
107 'facebooklinktext' => $options[ 'cff_facebook_link_text' ],
108 'viewlinktext' => $options[ 'cff_view_link_text' ],
109 'linktotimeline' => $options[ 'cff_link_to_timeline' ],
110 //Social
111 'iconstyle' => $options[ 'cff_icon_style' ],
112 'socialtextcolor' => $options[ 'cff_meta_text_color' ],
113 'socialbgcolor' => $options[ 'cff_meta_bg_color' ],
114 //Misc
115 'textlength' => get_option('cff_title_length'),
116 'desclength' => get_option('cff_body_length'),
117 'likeboxpos' => $options[ 'cff_like_box_position' ],
118 'likeboxoutside' => $options[ 'cff_like_box_outside' ],
119 'likeboxcolor' => $options[ 'cff_likebox_bg_color' ],
120 'likeboxwidth' => $options[ 'cff_likebox_width' ],
121 'likeboxfaces' => $options[ 'cff_like_box_faces' ],
122
123 'videoheight' => $options[ 'cff_video_height' ],
124 'videoaction' => $options[ 'cff_video_action' ],
125 'sepcolor' => $options[ 'cff_sep_color' ],
126 'sepsize' => $options[ 'cff_sep_size' ]
127 ), $atts);
128 /********** GENERAL **********/
129 $cff_feed_width = $atts['width'];
130 $cff_feed_height = $atts[ 'height' ];
131 $cff_feed_padding = $atts[ 'padding' ];
132 $cff_bg_color = $atts[ 'bgcolor' ];
133 $cff_show_author = $atts[ 'showauthor' ];
134 $cff_cache_time = $atts[ 'cachetime' ];
135 $cff_locale = $atts[ 'locale' ];
136 if ( empty($cff_locale) || !isset($cff_locale) || $cff_locale == '' ) $cff_locale = 'en_US';
137 if (!isset($cff_cache_time)) $cff_cache_time = 0;
138 $cff_cache_time_unit = $atts[ 'cacheunit' ];
139 $cff_class = $atts['class'];
140 //Compile feed styles
141 $cff_feed_styles = 'style="';
142 if ( !empty($cff_feed_width) ) $cff_feed_styles .= 'width:' . $cff_feed_width . '; ';
143 if ( !empty($cff_feed_height) ) $cff_feed_styles .= 'height:' . $cff_feed_height . '; ';
144 if ( !empty($cff_feed_padding) ) $cff_feed_styles .= 'padding:' . $cff_feed_padding . '; ';
145 if ( !empty($cff_bg_color) ) $cff_feed_styles .= 'background-color:#' . $cff_bg_color . '; ';
146 $cff_feed_styles .= '"';
147 //Like box
148 $cff_like_box_position = $atts[ 'likeboxpos' ];
149 $cff_like_box_outside = $atts[ 'likeboxoutside' ];
150 //Open links in new window?
151 $cff_open_links = $options[ 'cff_open_links' ];
152 $target = 'target="_blank"';
153 if ($cff_open_links) $target = 'target="_blank"';
154 /********** POST TYPES **********/
155 $cff_types = $atts[ 'type' ];
156 //Look for non-plural version of string in the types string in case user specifies singular in shortcode
157 $cff_show_links_type = true;
158 $cff_show_event_type = true;
159 $cff_show_video_type = true;
160 $cff_show_photos_type = true;
161 $cff_show_status_type = true;
162 $cff_events_only = false;
163 //Are we showing ONLY events?
164 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;
165 /********** LAYOUT **********/
166 $cff_includes = $atts[ 'include' ];
167 //Look for non-plural version of string in the types string in case user specifies singular in shortcode
168 if ( stripos($cff_includes, 'text') !== false ) $cff_show_text = true;
169 if ( stripos($cff_includes, 'desc') !== false ) $cff_show_desc = true;
170 if ( stripos($cff_includes, 'sharedlink') !== false ) $cff_show_shared_links = true;
171 if ( stripos($cff_includes, 'date') !== false ) $cff_show_date = true;
172 if ( stripos($cff_includes, 'media') !== false ) $cff_show_media = true;
173 if ( stripos($cff_includes, 'eventtitle') !== false ) $cff_show_event_title = true;
174 if ( stripos($cff_includes, 'eventdetail') !== false ) $cff_show_event_details = true;
175 if ( stripos($cff_includes, 'social') !== false ) $cff_show_meta = true;
176 if ( stripos($cff_includes, ',link') !== false ) $cff_show_link = true; //comma used to separate it from 'sharedlinks' - which also contains 'link' string
177 if ( stripos($cff_includes, 'like') !== false ) $cff_show_like_box = true;
178 $cff_preset_layout = 'thumb';
179
180 /********** META **********/
181 $cff_icon_style = $atts[ 'iconstyle' ];
182 $cff_meta_text_color = $atts[ 'socialtextcolor' ];
183 $cff_meta_bg_color = $atts[ 'socialbgcolor' ];
184 $cff_meta_styles = 'style="';
185 if ( !empty($cff_meta_text_color) ) $cff_meta_styles .= 'color:#' . $cff_meta_text_color . ';';
186 if ( !empty($cff_meta_bg_color) ) $cff_meta_styles .= 'background-color:#' . $cff_meta_bg_color . ';';
187 $cff_meta_styles .= '"';
188 $cff_nocomments_text = $options[ 'cff_nocomments_text' ];
189 $cff_hide_comments = $options[ 'cff_hide_comments' ];
190 if (!isset($cff_nocomments_text) || empty($cff_nocomments_text)) $cff_hide_comments = true;
191 /********** TYPOGRAPHY **********/
192 //See More text
193 $cff_see_more_text = $atts[ 'seemoretext' ];
194 $cff_see_less_text = $atts[ 'seelesstext' ];
195 //See Less text
196 //Title
197 $cff_title_format = $atts[ 'textformat' ];
198 if (empty($cff_title_format)) $cff_title_format = 'p';
199 $cff_title_size = $atts[ 'textsize' ];
200 $cff_title_weight = $atts[ 'textweight' ];
201 $cff_title_color = $atts[ 'textcolor' ];
202 $cff_title_styles = 'style="';
203 if ( !empty($cff_title_size) && $cff_title_size != 'inherit' ) $cff_title_styles .= 'font-size:' . $cff_title_size . 'px; ';
204 if ( !empty($cff_title_weight) && $cff_title_weight != 'inherit' ) $cff_title_styles .= 'font-weight:' . $cff_title_weight . '; ';
205 if ( !empty($cff_title_color) ) $cff_title_styles .= 'color:#' . $cff_title_color . ';';
206 $cff_title_styles .= '"';
207 $cff_title_link = $atts[ 'textlink' ];
208 //Description
209 $cff_body_size = $atts[ 'descsize' ];
210 $cff_body_weight = $atts[ 'descweight' ];
211 $cff_body_color = $atts[ 'desccolor' ];
212 $cff_body_styles = 'style="';
213 if ( !empty($cff_body_size) && $cff_body_size != 'inherit' ) $cff_body_styles .= 'font-size:' . $cff_body_size . 'px; ';
214 if ( !empty($cff_body_weight) && $cff_body_weight != 'inherit' ) $cff_body_styles .= 'font-weight:' . $cff_body_weight . '; ';
215 if ( !empty($cff_body_color) ) $cff_body_styles .= 'color:#' . $cff_body_color . ';';
216 $cff_body_styles .= '"';
217 //Event Title
218 $cff_event_title_format = $atts[ 'eventtitleformat' ];
219 if (empty($cff_event_title_format)) $cff_event_title_format = 'p';
220 $cff_event_title_size = $atts[ 'eventtitlesize' ];
221 $cff_event_title_weight = $atts[ 'eventtitleweight' ];
222 $cff_event_title_color = $atts[ 'eventtitlecolor' ];
223 $cff_event_title_styles = 'style="';
224 if ( !empty($cff_event_title_size) && $cff_event_title_size != 'inherit' ) $cff_event_title_styles .= 'font-size:' . $cff_event_title_size . 'px; ';
225 if ( !empty($cff_event_title_weight) && $cff_event_title_weight != 'inherit' ) $cff_event_title_styles .= 'font-weight:' . $cff_event_title_weight . '; ';
226 if ( !empty($cff_event_title_color) ) $cff_event_title_styles .= 'color:#' . $cff_event_title_color . ';';
227 $cff_event_title_styles .= '"';
228 $cff_event_title_link = $atts[ 'eventtitlelink' ];
229 //Event Date
230 $cff_event_date_size = $atts[ 'eventdatesize' ];
231 $cff_event_date_weight = $atts[ 'eventdateweight' ];
232 $cff_event_date_color = $atts[ 'eventdatecolor' ];
233 $cff_event_date_position = $atts[ 'eventdatepos' ];
234 $cff_event_date_formatting = $atts[ 'eventdateformat' ];
235 $cff_event_date_custom = $atts[ 'eventdatecustom' ];
236 $cff_event_date_styles = 'style="';
237 if ( !empty($cff_event_date_size) && $cff_event_date_size != 'inherit' ) $cff_event_date_styles .= 'font-size:' . $cff_event_date_size . 'px; ';
238 if ( !empty($cff_event_date_weight) && $cff_event_date_weight != 'inherit' ) $cff_event_date_styles .= 'font-weight:' . $cff_event_date_weight . '; ';
239 if ( !empty($cff_event_date_color) ) $cff_event_date_styles .= 'color:#' . $cff_event_date_color . ';';
240 $cff_event_date_styles .= '"';
241 //Event Details
242 $cff_event_details_size = $atts[ 'eventdetailssize' ];
243 $cff_event_details_weight = $atts[ 'eventdetailsweight' ];
244 $cff_event_details_color = $atts[ 'eventdetailscolor' ];
245 $cff_event_details_styles = 'style="';
246 if ( !empty($cff_event_details_size) && $cff_event_details_size != 'inherit' ) $cff_event_details_styles .= 'font-size:' . $cff_event_details_size . 'px; ';
247 if ( !empty($cff_event_details_weight) && $cff_event_details_weight != 'inherit' ) $cff_event_details_styles .= 'font-weight:' . $cff_event_details_weight . '; ';
248 if ( !empty($cff_event_details_color) ) $cff_event_details_styles .= 'color:#' . $cff_event_details_color . ';';
249 $cff_event_details_styles .= '"';
250 //Date
251 $cff_date_position = $atts[ 'datepos' ];
252 if (!isset($cff_date_position)) $cff_date_position = 'below';
253 $cff_date_size = $atts[ 'datesize' ];
254 $cff_date_weight = $atts[ 'dateweight' ];
255 $cff_date_color = $atts[ 'datecolor' ];
256 $cff_date_styles = 'style="';
257 if ( !empty($cff_date_size) && $cff_date_size != 'inherit' ) $cff_date_styles .= 'font-size:' . $cff_date_size . 'px; ';
258 if ( !empty($cff_date_weight) && $cff_date_weight != 'inherit' ) $cff_date_styles .= 'font-weight:' . $cff_date_weight . '; ';
259 if ( !empty($cff_date_color) ) $cff_date_styles .= 'color:#' . $cff_date_color . ';';
260 $cff_date_styles .= '"';
261 $cff_date_before = $options[ 'cff_date_before' ];
262 $cff_date_after = $options[ 'cff_date_after' ];
263 //Link to Facebook
264 $cff_link_size = $atts[ 'linksize' ];
265 $cff_link_weight = $atts[ 'linkweight' ];
266 $cff_link_color = $atts[ 'linkcolor' ];
267 $cff_link_styles = 'style="';
268 if ( !empty($cff_link_size) && $cff_link_size != 'inherit' ) $cff_link_styles .= 'font-size:' . $cff_link_size . 'px; ';
269 if ( !empty($cff_link_weight) && $cff_link_weight != 'inherit' ) $cff_link_styles .= 'font-weight:' . $cff_link_weight . '; ';
270 if ( !empty($cff_link_color) ) $cff_link_styles .= 'color:#' . $cff_link_color . ';';
271 $cff_link_styles .= '"';
272 $cff_facebook_link_text = $atts[ 'facebooklinktext' ];
273 $cff_view_link_text = $atts[ 'viewlinktext' ];
274 $cff_link_to_timeline = $atts[ 'linktotimeline' ];
275 /********** MISC **********/
276 //Like Box styles
277 $cff_likebox_bg_color = $atts[ 'likeboxcolor' ];
278 $cff_likebox_styles = 'style="';
279 if ( !empty($cff_likebox_bg_color) ) $cff_likebox_styles .= 'background-color:#' . $cff_likebox_bg_color . '; margin-left: 0; ';
280 $cff_likebox_styles .= '"';
281 //Video
282 //Dimensions
283 $cff_video_width = 640;
284 $cff_video_height = $atts[ 'videoheight' ];
285
286 if ($cff_thumb_layout) {
287 if(empty($cff_video_height)) $cff_video_height = 100;
288 } else if ($cff_half_layout) {
289 if(empty($cff_video_height)) $cff_video_height = 180;
290 } else {
291 if(empty($cff_video_height)) $cff_video_height = 360;
292 }
293 //Action
294 $cff_video_action = $atts[ 'videoaction' ];
295 //Separating Line
296 $cff_sep_color = $atts[ 'sepcolor' ];
297 if (empty($cff_sep_color)) $cff_sep_color = 'ddd';
298 $cff_sep_size = $atts[ 'sepsize' ];
299 if (empty($cff_sep_size)) $cff_sep_size = 0;
300 //CFF item styles
301 $cff_item_styles = 'style="';
302 $cff_item_styles .= 'border-bottom: ' . $cff_sep_size . 'px solid #' . $cff_sep_color . '; ';
303 $cff_item_styles .= '"';
304
305 //Text limits
306 $title_limit = $atts['textlength'];
307 if (!isset($title_limit)) $title_limit = 9999;
308 $body_limit = $atts['desclength'];
309 //Assign the Access Token and Page ID variables
310 $access_token = get_option('cff_access_token');
311 $page_id = $atts['id'];
312 //Get show posts attribute. If not set then default to 25
313 $show_posts = $atts['num'];
314 if (empty($show_posts)) $show_posts = 25;
315 if ( $show_posts == 0 || $show_posts == undefined ) $show_posts = 25;
316 //Check whether the Access Token is present and valid
317 if ($access_token == '') {
318 echo 'Please enter a valid Access Token. You can do this in the Custom Facebook Feed plugin settings.<br /><br />';
319 return false;
320 }
321 //Check whether a Page ID has been defined
322 if ($page_id == '') {
323 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 />";
324 return false;
325 }
326 //Use posts? or feed?
327 $show_others = $atts['others'];
328 $graph_query = 'posts';
329 if ($show_others == 'true') $graph_query = 'feed';
330 $cff_post_limit = $atts['limit'];
331 //Calculate the cache time in seconds
332 if($cff_cache_time_unit == 'minutes') $cff_cache_time_unit = 60;
333 if($cff_cache_time_unit == 'hours') $cff_cache_time_unit = 60*60;
334 if($cff_cache_time_unit == 'days') $cff_cache_time_unit = 60*60*24;
335 $cache_seconds = $cff_cache_time * $cff_cache_time_unit;
336
337 //Get like box vars
338 $cff_likebox_width = $atts[ 'likeboxwidth' ];
339 if ( !isset($cff_likebox_width) || empty($cff_likebox_width) || $cff_likebox_width == '' ) $cff_likebox_width = 300;
340 $cff_like_box_faces = $atts[ 'likeboxfaces' ];
341 if ( !isset($cff_like_box_faces) || empty($cff_like_box_faces) ) $cff_like_box_faces = 'false';
342
343 //Set like box variable
344 $like_box = '<div class="cff-likebox';
345 if ($cff_like_box_outside) $like_box .= ' cff-outside';
346 $like_box .= ($cff_like_box_position == 'top') ? ' cff-top' : ' cff-bottom';
347 $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 . '" width="'.$cff_likebox_width.'" show_faces="'.$cff_like_box_faces.'" stream="false" header="false"></fb:like-box></div>';
348 //***START FEED***
349 $content = '';
350 //Add like box to the outside of the top of feed
351 if ($cff_like_box_position == 'top' && $cff_show_like_box && $cff_like_box_outside) $content .= $like_box;
352 //Create CFF container HTML
353 $content .= '<div id="cff" rel="'.$title_limit.'" class="';
354 if( !empty($cff_class) ) $content .= $cff_class . ' ';
355 if ( !empty($cff_feed_height) ) $content .= 'cff-fixed-height ';
356 if ( $cff_thumb_layout ) $content .= 'cff-thumb-layout ';
357 // if ( $cff_media_medium ) $content .= 'medium-image ';
358 if ( $cff_half_layout ) $content .= 'cff-half-layout ';
359 $content .= '" ' . $cff_feed_styles . '>';
360 //Add like box to the inside of the top of feed
361 if ($cff_like_box_position == 'top' && $cff_show_like_box && !$cff_like_box_outside) $content .= $like_box;
362 //Limit var
363 $i = 0;
364
365
366 //ALL POSTS
367 if (!$cff_events_only){
368
369 $cff_posts_json_url = 'https://graph.facebook.com/' . $page_id . '/' . $graph_query . '?access_token=' . $access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale;
370
371 //Don't use caching if the cache time is set to zero
372 if ($cff_cache_time != 0){
373 // Get any existing copy of our transient data
374 $transient_name = 'cff_'. $graph_query .'_json_' . $page_id;
375 if ( false === ( $posts_json = get_transient( $transient_name ) ) || $posts_json === null ) {
376 //Get the contents of the Facebook page
377 $posts_json = cff_fetchUrl($cff_posts_json_url);
378 //Cache the JSON
379 set_transient( $transient_name, $posts_json, $cache_seconds );
380 } else {
381 $posts_json = get_transient( $transient_name );
382 }
383 } else {
384 $posts_json = cff_fetchUrl($cff_posts_json_url);
385 }
386
387 //Interpret data with JSON
388 $FBdata = json_decode($posts_json);
389 //***STARTS POSTS LOOP***
390 foreach ($FBdata->data as $news )
391 {
392 //Explode News and Page ID's into 2 values
393 $PostID = explode("_", $news->id);
394 //Check the post type
395 $cff_post_type = $news->type;
396 if ($cff_post_type == 'link') {
397 $story = $news->story;
398 //Check whether it's an event
399 $created_event = 'created an event.';
400 $shared_event = 'shared an event.';
401 $created_event = stripos($story, $created_event);
402 $shared_event = stripos($story, $shared_event);
403 if ( $created_event || $shared_event ) $cff_post_type = 'event';
404 }
405 //Should we show this post or not?
406 $cff_show_post = false;
407 switch ($cff_post_type) {
408 case 'link':
409 if ( $cff_show_links_type ) $cff_show_post = true;
410 break;
411 case 'event':
412 if ( $cff_show_event_type ) $cff_show_post = true;
413 break;
414 case 'video':
415 if ( $cff_show_video_type ) $cff_show_post = true;
416 break;
417 case 'swf':
418 if ( $cff_show_video_type ) $cff_show_post = true;
419 break;
420 case 'photo':
421 if ( $cff_show_photos_type ) $cff_show_post = true;
422 break;
423 case 'offer':
424 $cff_show_post = true;
425 break;
426 case 'status':
427 //Check whether it's a status (author comment or like)
428 if ( $cff_show_status_type && !empty($news->message) ) $cff_show_post = true;
429 break;
430 }
431 //Is it a duplicate post?
432 if ( ($prev_post_message == $news->message) && ($prev_post_link == $news->link) && ($prev_post_description == $news->description) ) $cff_show_post = false;
433 //Check post type and display post if selected
434 if ( $cff_show_post ) {
435 //If it isn't then create the post
436 //Only create posts for the amount of posts specified
437 if ( $i == $show_posts ) break;
438 $i++;
439 //********************************//
440 //***COMPILE SECTION VARIABLES***//
441 //********************************//
442 //Set the post link
443 $link = $news->link;
444 //Is it a shared album?
445 $shared_album_string = 'shared an album:';
446 $shared_album = stripos($news->story, $shared_album_string);
447 if ( $shared_album ) {
448 $link = str_replace('photo.php?','media/set/?',$link);
449 }
450
451 //If there's no link provided then link to either the Facebook page or the individual status
452 if (empty($news->link)) {
453 if ($cff_link_to_timeline == true){
454 //Link to page
455 $link = 'http://facebook.com/' . $page_id;
456 } else {
457 //Link to status
458 $link = "https://www.facebook.com/" . $page_id . "/posts/" . $PostID[1];
459 }
460 }
461
462 //POST AUTHOR
463 $cff_author = '<a class="cff-author" href="http://facebook.com/' . $news->from->id . '" '.$target.' title="'.$news->from->name.' on Facebook">';
464 $cff_author .= '<img src="http://graph.facebook.com/' . $news->from->id . '/picture">';
465 $cff_author .= '<p>'.$news->from->name.'</p>';
466 $cff_author .= '</a>';
467 //POST TEXT
468 $cff_post_text = '<' . $cff_title_format . ' class="cff-post-text" ' . $cff_title_styles . '>';
469 $cff_post_text .= '<span class="cff-text">';
470 if ($cff_title_link) $cff_post_text .= '<a class="cff-post-text-link" href="'.$link.'" '.$target.'>';
471 if (!empty($news->story)) $post_text = $news->story;
472 if (!empty($news->message)) $post_text = $news->message;
473 //Use the name if neither the story or message are available, or if the post type is an offer
474 if ( (!empty($news->name) && empty($news->story) && empty($news->message)) || $cff_post_type == 'offer') $post_text = $news->name;
475 //If the text is wrapped in a link then don't hyperlink any text within
476 if ($cff_title_link) {
477 //Wrap links in a span so we can break the text if it's too long
478 $cff_post_text .= cff_wrap_span($post_text) . ' ';
479 } else {
480 $cff_post_text .= cff_make_clickable($post_text) . ' ';
481 }
482
483 if ($cff_title_link) $cff_post_text .= '</a>';
484 $cff_post_text .= '</span>';
485 //'See More' link
486 $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>';
487 $cff_post_text .= '</' . $cff_title_format . '>';
488 //DESCRIPTION
489 $cff_description = '';
490 //Use the description if it's available and the post type isn't set to offer (offer description isn't useful)
491 if (!empty($news->description) && $cff_post_type != 'offer') {
492 $description_text = $news->description;
493 if (!empty($body_limit)) {
494 if (strlen($description_text) > $body_limit) $description_text = substr($description_text, 0, $body_limit) . '...';
495 }
496 $cff_description .= '<p class="cff-post-desc" '.$cff_body_styles.'><span>' . cff_make_clickable($description_text) . '</span></p>';
497 }
498 //LINK
499 $cff_shared_link = '';
500 //Display shared link
501 if ($news->type == 'link') {
502 //Display link name and description
503 if (!empty($news->description)) {
504 $cff_shared_link .= '<p class="cff-text-link ';
505 $cff_shared_link .= 'cff-no-image';
506 $cff_shared_link .= '"><a href="'.$link.'" '.$target.'>'. '<b>' . $news->name . '</b></a></p>';
507 }
508 }
509 //DATE
510 $cff_date_formatting = $atts[ 'dateformat' ];
511 $cff_date_custom = $atts[ 'datecustom' ];
512 $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>';
513 //EVENT
514 $cff_event = '';
515 if ($cff_show_event_title || $cff_show_event_details) {
516 //Check for media
517 if ($cff_post_type == 'event') {
518
519 //Get the event object
520 $eventID = $PostID[1];
521 if ( $shared_event ) {
522 //Get the event id from the event URL. eg: http://www.facebook.com/events/123451234512345/
523 $event_url = parse_url($link);
524 $url_parts = explode('/', $event_url['path']);
525 //Get the id from the parts
526 $eventID = $url_parts[count($url_parts)-2];
527 }
528 //Get the contents of the event using the WP HTTP API
529 $event_json = cff_fetchUrl('https://graph.facebook.com/'.$eventID.'?access_token=' . $access_token);
530 //Interpret data with JSON
531 $event_object = json_decode($event_json);
532 //Event date
533 $event_time = $event_object->start_time;
534 //If timezone migration is enabled then remove last 5 characters
535 if ( strlen($event_time) == 24 ) $event_time = substr($event_time, 0, -5);
536 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>';
537 //EVENT
538 //Display the event details
539 $cff_event .= '<div class="cff-details">';
540 //show event date above title
541 if ($cff_event_date_position == 'above') $cff_event .= $cff_event_date;
542 //Show event title
543 if ($cff_show_event_title && !empty($event_object->name)) {
544 if ($cff_event_title_link) $cff_event .= '<a href="'.$link.'">';
545 $cff_event .= '<' . $cff_event_title_format . ' ' . $cff_event_title_styles . '>' . $event_object->name . '</' . $cff_event_title_format . '>';
546 if ($cff_event_title_link) $cff_event .= '</a>';
547 }
548 //show event date below title
549 if ($cff_event_date_position !== 'above') $cff_event .= $cff_event_date;
550 //Show event details
551 if ($cff_show_event_details){
552 //Location
553 if (!empty($event_object->location)) $cff_event .= '<p class="cff-where" ' . $cff_event_details_styles . '>' . $event_object->location . '</p>';
554 //Description
555 if (!empty($event_object->description)){
556 $description = $event_object->description;
557 if (!empty($body_limit)) {
558 if (strlen($description) > $body_limit) $description = substr($description, 0, $body_limit) . '...';
559 }
560 $cff_event .= '<p class="cff-info" ' . $cff_event_details_styles . '>' . cff_make_clickable($description) . '</p>';
561 }
562 }
563 $cff_event .= '</div>';
564
565 }
566 }
567
568 //Display the link to the Facebook post or external link
569 $cff_link = '';
570 //Default link
571 $cff_viewpost_class = 'cff-viewpost-facebook';
572 if ($cff_facebook_link_text == '') $cff_facebook_link_text = 'View on Facebook';
573 $link_text = $cff_facebook_link_text;
574 if (!empty($news->link)) {
575 //Check whether it links to facebook or somewhere else
576 $facebook_str = 'facebook.com';
577 if(stripos($link, $facebook_str) == false) {
578 if ($cff_view_link_text == '') $cff_view_link_text = 'View Link';
579 $link_text = $cff_view_link_text;
580 }
581 $cff_viewpost_class = 'cff-viewpost-link';
582 }
583 if ($cff_post_type == 'offer') $link_text = 'View Offer';
584 $cff_link = '<a class="' . $cff_viewpost_class . '" href="' . $link . '" title="' . $link_text . '" ' . $target . ' ' . $cff_link_styles . '>' . $link_text . '</a>';
585 //Compile the meta and link if included
586 if ($cff_show_meta) $cff_meta_total .= $cff_meta;
587 if ($cff_show_link) $cff_meta_total .= $cff_link;
588 $cff_meta_total .= '</div>';
589 $cff_comments = '';
590 //Compile comments if meta is included
591 if ($cff_show_meta) $cff_meta_total .= $cff_comments;
592 //**************************//
593 //***CREATE THE POST HTML***//
594 //**************************//
595 //Start the container
596 $content .= '<div class="cff-item ';
597 if ($cff_post_type == 'link') $content .= 'cff-link-item';
598 if ($cff_post_type == 'event') $content .= 'cff-timeline-event';
599 if ($cff_post_type == 'photo') $content .= 'cff-photo-post';
600 if ($cff_post_type == 'video') $content .= 'cff-video-post';
601 if ($cff_post_type == 'swf') $content .= 'cff-swf-post';
602 if ($cff_post_type == 'status') $content .= 'cff-status-post';
603 if ($cff_post_type == 'offer') $content .= 'cff-offer-post';
604 $content .= '" id="'. $news->id .'" ' . $cff_item_styles . '>';
605
606 //POST AUTHOR
607 if($cff_show_author) $content .= $cff_author;
608 //DATE ABOVE
609 if ($cff_show_date && $cff_date_position == 'above') $content .= $cff_date;
610 //POST TEXT
611 if($cff_show_text) $content .= $cff_post_text;
612 //DESCRIPTION
613 if($cff_show_desc) $content .= $cff_description;
614 //LINK
615 if($cff_show_shared_links) $content .= $cff_shared_link;
616 //DATE BELOW
617 if ($cff_show_date && $cff_date_position == 'below') $content .= $cff_date;
618 //EVENT
619 if($cff_show_event_title || $cff_show_event_details) $content .= $cff_event;
620 //VIEW ON FACEBOOK LINK
621 if($cff_show_link) $content .= $cff_link;
622
623 //End the post item
624 $content .= '</div><div class="cff-clear"></div>';
625 } // End post type check
626 $prev_post_message = $news->message;
627 $prev_post_link = $news->link;
628 $prev_post_description = $news->description;
629 } // End the loop
630 } // End ALL POSTS
631 //Load more posts
632 // $content .= '<button class="loadmore">Load More Posts</button>';
633 //Add the Like Box inside
634 if ($cff_like_box_position == 'bottom' && $cff_show_like_box && !$cff_like_box_outside) $content .= $like_box;
635 //End the feed
636 $content .= '</div><div class="cff-clear"></div>';
637 //Add the Like Box outside
638 if ($cff_like_box_position == 'bottom' && $cff_show_like_box && $cff_like_box_outside) $content .= $like_box;
639 //Return our feed HTML to display
640 return $content;
641 }
642 //Get JSON object of feed data
643 function cff_fetchUrl($url){
644 //Can we use cURL?
645 if(is_callable('curl_init')){
646 $ch = curl_init();
647 curl_setopt($ch, CURLOPT_URL, $url);
648 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
649 curl_setopt($ch, CURLOPT_TIMEOUT, 20);
650 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
651 $feedData = curl_exec($ch);
652 curl_close($ch);
653 //If not then use file_get_contents
654 } elseif ( ini_get('allow_url_fopen') == 1 || ini_get('allow_url_fopen') === TRUE ) {
655 $feedData = @file_get_contents($url);
656 //Or else use the WP HTTP API
657 } else {
658 if( !class_exists( 'WP_Http' ) ) include_once( ABSPATH . WPINC. '/class-http.php' );
659 $request = new WP_Http;
660 $result = $request->request($url);
661 $feedData = $result['body'];
662 }
663
664 return $feedData;
665 }
666 //***FUNCTIONS***
667 //Make links in text clickable
668 function cff_make_clickable($text) {
669 $pattern = '#\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))#';
670 return preg_replace_callback($pattern, 'cff_auto_link_text_callback', $text);
671 }
672 function cff_auto_link_text_callback($matches) {
673 $max_url_length = 50;
674 $max_depth_if_over_length = 2;
675 $ellipsis = '&hellip;';
676 $target = 'target="_blank"';
677 $url_full = $matches[0];
678 $url_short = '';
679 if (strlen($url_full) > $max_url_length) {
680 $parts = parse_url($url_full);
681 $url_short = $parts['scheme'] . '://' . preg_replace('/^www\./', '', $parts['host']) . '/';
682 $path_components = explode('/', trim($parts['path'], '/'));
683 foreach ($path_components as $dir) {
684 $url_string_components[] = $dir . '/';
685 }
686 if (!empty($parts['query'])) {
687 $url_string_components[] = '?' . $parts['query'];
688 }
689 if (!empty($parts['fragment'])) {
690 $url_string_components[] = '#' . $parts['fragment'];
691 }
692 for ($k = 0; $k < count($url_string_components); $k++) {
693 $curr_component = $url_string_components[$k];
694 if ($k >= $max_depth_if_over_length || strlen($url_short) + strlen($curr_component) > $max_url_length) {
695 if ($k == 0 && strlen($url_short) < $max_url_length) {
696 // Always show a portion of first directory
697 $url_short .= substr($curr_component, 0, $max_url_length - strlen($url_short));
698 }
699 $url_short .= $ellipsis;
700 break;
701 }
702 $url_short .= $curr_component;
703 }
704 } else {
705 $url_short = $url_full;
706 }
707 return "<a class='cff-break-word' rel=\"nofollow\" href=\"$url_full\">$url_full</a>";
708 }
709 //Make links into span instead when the post text is made clickable
710 function cff_wrap_span($text) {
711 $pattern = '#\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))#';
712 return preg_replace_callback($pattern, 'cff_wrap_span_callback', $text);
713 }
714 function cff_wrap_span_callback($matches) {
715 $max_url_length = 50;
716 $max_depth_if_over_length = 2;
717 $ellipsis = '&hellip;';
718 $target = 'target="_blank"';
719 $url_full = $matches[0];
720 $url_short = '';
721 if (strlen($url_full) > $max_url_length) {
722 $parts = parse_url($url_full);
723 $url_short = $parts['scheme'] . '://' . preg_replace('/^www\./', '', $parts['host']) . '/';
724 $path_components = explode('/', trim($parts['path'], '/'));
725 foreach ($path_components as $dir) {
726 $url_string_components[] = $dir . '/';
727 }
728 if (!empty($parts['query'])) {
729 $url_string_components[] = '?' . $parts['query'];
730 }
731 if (!empty($parts['fragment'])) {
732 $url_string_components[] = '#' . $parts['fragment'];
733 }
734 for ($k = 0; $k < count($url_string_components); $k++) {
735 $curr_component = $url_string_components[$k];
736 if ($k >= $max_depth_if_over_length || strlen($url_short) + strlen($curr_component) > $max_url_length) {
737 if ($k == 0 && strlen($url_short) < $max_url_length) {
738 // Always show a portion of first directory
739 $url_short .= substr($curr_component, 0, $max_url_length - strlen($url_short));
740 }
741 $url_short .= $ellipsis;
742 break;
743 }
744 $url_short .= $curr_component;
745 }
746 } else {
747 $url_short = $url_full;
748 }
749 return "<span class='cff-break-word'>$url_short</span>";
750 }
751 //2013-04-28T21:06:56+0000
752 //Time stamp function - used for posts
753 function cff_getdate($original, $date_format, $custom_date) {
754 switch ($date_format) {
755
756 case '2':
757 $print = date('F jS, g:i a', $original);
758 break;
759 case '3':
760 $print = date('F jS', $original);
761 break;
762 case '4':
763 $print = date('D F jS', $original);
764 break;
765 case '5':
766 $print = date('l F jS', $original);
767 break;
768 case '6':
769 $print = date('D M jS, Y', $original);
770 break;
771 case '7':
772 $print = date('l F jS, Y', $original);
773 break;
774 case '8':
775 $print = date('l F jS, Y - g:i a', $original);
776 break;
777 case '9':
778 $print = date("l M jS, 'y", $original);
779 break;
780 case '10':
781 $print = date('m.d.y', $original);
782 break;
783 case '11':
784 $print = date('m/d/y', $original);
785 break;
786 case '12':
787 $print = date('d.m.y', $original);
788 break;
789 case '13':
790 $print = date('d/m/y', $original);
791 break;
792 default:
793
794 $periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
795 $lengths = array("60","60","24","7","4.35","12","10");
796 $now = time();
797
798 // is it future date or past date
799 if($now > $original) {
800 $difference = $now - $original;
801 $tense = "ago";
802 } else {
803 $difference = $original - $now;
804 $tense = "from now";
805 }
806 for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
807 $difference /= $lengths[$j];
808 }
809
810 $difference = round($difference);
811
812 if($difference != 1) {
813 $periods[$j].= "s";
814 }
815 $print = "$difference $periods[$j] {$tense}";
816 break;
817
818 }
819 if ( !empty($custom_date) ){
820 $print = date($custom_date, $original);
821 }
822 return $print;
823 }
824 function cff_eventdate($original, $date_format, $custom_date) {
825 switch ($date_format) {
826
827 case '2':
828 $print = date('F jS, g:ia', $original);
829 break;
830 case '3':
831 $print = date('g:ia - F jS', $original);
832 break;
833 case '4':
834 $print = date('g:ia, F jS', $original);
835 break;
836 case '5':
837 $print = date('l F jS - g:ia', $original);
838 break;
839 case '6':
840 $print = date('D M jS, Y, g:iA', $original);
841 break;
842 case '7':
843 $print = date('l F jS, Y, g:iA', $original);
844 break;
845 case '8':
846 $print = date('l F jS, Y - g:ia', $original);
847 break;
848 case '9':
849 $print = date("l M jS, 'y", $original);
850 break;
851 case '10':
852 $print = date('m.d.y - g:iA', $original);
853 break;
854 case '11':
855 $print = date('m/d/y, g:ia', $original);
856 break;
857 case '12':
858 $print = date('d.m.y - g:iA', $original);
859 break;
860 case '13':
861 $print = date('d/m/y, g:ia', $original);
862 break;
863 default:
864 $print = date('F j, Y, g:ia', $original);
865 break;
866 }
867 if ( !empty($custom_date) ){
868 $print = date($custom_date, $original);
869 }
870 return $print;
871 }
872 //Time stamp function - used for comments
873 function cff_timesince($original) {
874
875 $periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
876 $lengths = array("60","60","24","7","4.35","12","10");
877 $now = time();
878
879 // is it future date or past date
880 if($now > $original) {
881 $difference = $now - $original;
882 $tense = "ago";
883 } else {
884 $difference = $original - $now;
885 $tense = "from now";
886 }
887 for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
888 $difference /= $lengths[$j];
889 }
890
891 $difference = round($difference);
892
893 if($difference != 1) {
894 $periods[$j].= "s";
895 }
896 return "$difference $periods[$j] {$tense}";
897
898 }
899 //Use custom stripos function if it's not available (only available in PHP 5+)
900 if(!is_callable('stripos')){
901 function stripos($haystack, $needle){
902 return strpos($haystack, stristr( $haystack, $needle ));
903 }
904 }
905
906 // remove_filter( 'the_content', 'wpautop' );
907 // add_filter( 'the_content', 'wpautop', 99 );
908
909 //Enqueue stylesheet
910 add_action( 'wp_enqueue_scripts', 'cff_add_my_stylesheet' );
911 function cff_add_my_stylesheet() {
912 // Respects SSL, Style.css is relative to the current file
913 wp_register_style( 'cff', plugins_url('css/cff-style.css?3', __FILE__) );
914 wp_enqueue_style( 'cff' );
915 }
916 //Enqueue scripts
917 add_action( 'wp_enqueue_scripts', 'cff_scripts_method' );
918 function cff_scripts_method() {
919 wp_enqueue_script(
920 'cffscripts',
921 plugins_url( '/js/cff-scripts.js?3' , __FILE__ ),
922 array( 'jquery' )
923 );
924 }
925 //Allows shortcodes in theme
926 add_filter('widget_text', 'do_shortcode');
927 function cff_activate() {
928 $options = get_option('cff_style_settings');
929 $options[ 'cff_show_links_type' ] = true;
930 $options[ 'cff_show_event_type' ] = true;
931 $options[ 'cff_show_video_type' ] = true;
932 $options[ 'cff_show_photos_type' ] = true;
933 $options[ 'cff_show_status_type' ] = true;
934 // Show all parts of the feed by default on activation
935 $options[ 'cff_show_text' ] = true;
936 $options[ 'cff_show_desc' ] = true;
937 $options[ 'cff_show_shared_links' ] = true;
938 $options[ 'cff_show_date' ] = true;
939 $options[ 'cff_show_media' ] = true;
940 $options[ 'cff_show_event_title' ] = true;
941 $options[ 'cff_show_event_details' ] = true;
942 $options[ 'cff_show_meta' ] = true;
943 $options[ 'cff_show_link' ] = true;
944 $options[ 'cff_show_like_box' ] = true;
945 update_option( 'cff_style_settings', $options );
946 }
947 register_activation_hook( __FILE__, 'cff_activate' );
948 //Uninstall
949 function cff_uninstall()
950 {
951 if ( ! current_user_can( 'activate_plugins' ) )
952 return;
953 //Settings
954 delete_option( 'cff_access_token' );
955 delete_option( 'cff_page_id' );
956 delete_option( 'cff_num_show' );
957 delete_option( 'cff_post_limit' );
958 delete_option( 'cff_show_others' );
959 delete_option('cff_cache_time');
960 delete_option('cff_cache_time_unit');
961 delete_option( 'cff_locale' );
962 //Style & Layout
963 delete_option( 'cff_title_length' );
964 delete_option( 'cff_body_length' );
965 delete_option('cff_style_settings');
966 }
967 register_uninstall_hook( __FILE__, 'cff_uninstall' );
968 add_action( 'wp_head', 'cff_custom_css' );
969 function cff_custom_css() {
970 $options = get_option('cff_style_settings');
971 $cff_custom_css = $options[ 'cff_custom_css' ];
972 echo '<!-- Custom Facebook Feed Custom CSS -->';
973 echo "\r\n";
974 echo '<style type="text/css">';
975 echo "\r\n";
976 echo $cff_custom_css;
977 echo "\r\n";
978 echo '</style>';
979 echo "\r\n";
980 }
981 add_action( 'wp_footer', 'cff_js' );
982 function cff_js() {
983 // $path = site_url();
984 $url = site_url();
985 $path = urlencode(ABSPATH);
986 echo '<!-- Custom Facebook Feed JS -->';
987 echo "\r\n";
988 echo '<script type="text/javascript">';
989 echo "\r\n";
990 echo 'var siteURL = "' . $url . '";';
991 echo "\r\n";
992 echo 'var rootPath = "' . $path . '";';
993 echo "\r\n";
994 echo '</script>';
995 echo "\r\n";
996 }
997
998 //Comment out the line below to view errors
999 error_reporting(0);
1000 ?>