PluginProbe ʕ •ᴥ•ʔ
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress / 1.4.1
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress v1.4.1
4.8.1 trunk 1.0 1.1 1.12.1 1.2.3 1.2.4 1.2.5 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.5 1.5.1 1.5.2 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.4.1 1.6.5 1.6.5.1 1.6.6 1.6.6.1 1.6.6.2 1.6.6.3 1.6.7 1.6.7.1 1.6.8 1.6.8.1 1.6.8.2 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.9.0 1.9.1 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.8.1 1.9.9 1.9.9.1 1.9.9.2 1.9.9.3 2.0 2.0.1 2.1 2.1.1 2.1.2 2.1.3 2.10 2.11 2.11.1 2.12 2.12.1 2.12.2 2.12.3 2.12.4 2.13 2.14 2.14.1 2.15 2.15.1 2.16 2.16.1 2.17 2.17.1 2.18 2.18.1 2.18.2 2.18.3 2.19 2.19.1 2.19.2 2.19.3 2.2 2.2.1 2.3 2.3.1 2.3.10 2.3.2 2.3.3 2.3.4 2.3.6 2.3.7 2.3.8 2.3.9 2.4 2.4.1 2.4.1.1 2.4.1.2 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5 2.5.1 2.5.2 2.6 2.6.1 2.6.2 2.6.3 2.6.4 2.7 2.7.1 2.7.2 2.8 2.9 2.9.1 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.1 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.7.5 4.7.6 4.7.7
custom-facebook-feed / custom-facebook-feed.php
custom-facebook-feed Last commit date
css 12 years ago img 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
551 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.4.1
7 Author: Smash Balloon
8 Author URI: http://smashballoon.com/
9 License: GPLv2 or later
10 */
11
12 /*
13 Copyright 2013 Smash Balloon (email : hey@smashballoon.com)
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 */
26
27 //Include admin
28 include dirname( __FILE__ ) .'/custom-facebook-feed-admin.php';
29
30 // Add shortcodes
31 add_shortcode('custom-facebook-feed', 'display_cff');
32 function display_cff($atts) {
33
34 //Style options
35 $options = get_option('cff_style_settings');
36
37
38 /********** GENERAL **********/
39
40 $cff_feed_width = $options[ 'cff_feed_width' ];
41 $cff_feed_height = $options[ 'cff_feed_height' ];
42 $cff_feed_padding = $options[ 'cff_feed_padding' ];
43 $cff_bg_color = $options[ 'cff_bg_color' ];
44
45 //Compile feed styles
46 $cff_feed_styles = 'style="';
47 if ( !empty($cff_feed_width) ) $cff_feed_styles .= 'width:' . $cff_feed_width . '; ';
48 if ( !empty($cff_feed_height) ) $cff_feed_styles .= 'height:' . $cff_feed_height . '; ';
49 if ( !empty($cff_feed_padding) ) $cff_feed_styles .= 'padding:' . $cff_feed_padding . '; ';
50 if ( !empty($cff_bg_color) ) $cff_feed_styles .= 'background-color:#' . $cff_bg_color . '; ';
51 $cff_feed_styles .= '"';
52
53 //Like box
54 $cff_like_box_position = $options[ 'cff_like_box_position' ];
55
56 //Open links in new window?
57 $cff_open_links = $options[ 'cff_open_links' ];
58 $target = 'target="_blank"';
59 if ($cff_open_links) $target = 'target="_blank"';
60
61
62 /********** LAYOUT **********/
63
64 //Include
65 $cff_show_text = $options[ 'cff_show_text' ];
66 $cff_show_desc = $options[ 'cff_show_desc' ];
67 $cff_show_date = $options[ 'cff_show_date' ];
68 $cff_show_event_title = $options[ 'cff_show_event_title' ];
69 $cff_show_event_details = $options[ 'cff_show_event_details' ];
70 $cff_show_link = $options[ 'cff_show_link' ];
71 $cff_show_like_box = $options[ 'cff_show_like_box' ];
72
73
74 /********** TYPOGRAPHY **********/
75
76 //Title
77 $cff_title_format = $options[ 'cff_title_format' ];
78 if (empty($cff_title_format)) $cff_title_format = 'p';
79 $cff_title_size = $options[ 'cff_title_size' ];
80 $cff_title_weight = $options[ 'cff_title_weight' ];
81 $cff_title_color = $options[ 'cff_title_color' ];
82 $cff_title_styles = 'style="';
83 if ( !empty($cff_title_size) && $cff_title_size != 'inherit' ) $cff_title_styles .= 'font-size:' . $cff_title_size . 'px; ';
84 if ( !empty($cff_title_weight) && $cff_title_weight != 'inherit' ) $cff_title_styles .= 'font-weight:' . $cff_title_weight . '; ';
85 if ( !empty($cff_title_color) ) $cff_title_styles .= 'color:#' . $cff_title_color . ';';
86 $cff_title_styles .= '"';
87
88 //Description
89 $cff_body_size = $options[ 'cff_body_size' ];
90 $cff_body_weight = $options[ 'cff_body_weight' ];
91 $cff_body_color = $options[ 'cff_body_color' ];
92 $cff_body_styles = 'style="';
93 if ( !empty($cff_body_size) && $cff_body_size != 'inherit' ) $cff_body_styles .= 'font-size:' . $cff_body_size . 'px; ';
94 if ( !empty($cff_body_weight) && $cff_body_weight != 'inherit' ) $cff_body_styles .= 'font-weight:' . $cff_body_weight . '; ';
95 if ( !empty($cff_body_color) ) $cff_body_styles .= 'color:#' . $cff_body_color . ';';
96 $cff_body_styles .= '"';
97
98 //Event Title
99 $cff_event_title_format = $options[ 'cff_event_title_format' ];
100 if (empty($cff_event_title_format)) $cff_event_title_format = 'p';
101 $cff_event_title_size = $options[ 'cff_event_title_size' ];
102 $cff_event_title_weight = $options[ 'cff_event_title_weight' ];
103 $cff_event_title_color = $options[ 'cff_event_title_color' ];
104 $cff_event_title_styles = 'style="';
105 if ( !empty($cff_event_title_size) && $cff_event_title_size != 'inherit' ) $cff_event_title_styles .= 'font-size:' . $cff_event_title_size . 'px; ';
106 if ( !empty($cff_event_title_weight) && $cff_event_title_weight != 'inherit' ) $cff_event_title_styles .= 'font-weight:' . $cff_event_title_weight . '; ';
107 if ( !empty($cff_event_title_color) ) $cff_event_title_styles .= 'color:#' . $cff_event_title_color . ';';
108 $cff_event_title_styles .= '"';
109
110 //Event Details
111 $cff_event_details_size = $options[ 'cff_event_details_size' ];
112 $cff_event_details_weight = $options[ 'cff_event_details_weight' ];
113 $cff_event_details_color = $options[ 'cff_event_details_color' ];
114 $cff_event_details_styles = 'style="';
115 if ( !empty($cff_event_details_size) && $cff_event_details_size != 'inherit' ) $cff_event_details_styles .= 'font-size:' . $cff_event_details_size . 'px; ';
116 if ( !empty($cff_event_details_weight) && $cff_event_details_weight != 'inherit' ) $cff_event_details_styles .= 'font-weight:' . $cff_event_details_weight . '; ';
117 if ( !empty($cff_event_details_color) ) $cff_event_details_styles .= 'color:#' . $cff_event_details_color . ';';
118 $cff_event_details_styles .= '"';
119
120 //Date
121 $cff_date_size = $options[ 'cff_date_size' ];
122 $cff_date_weight = $options[ 'cff_date_weight' ];
123 $cff_date_color = $options[ 'cff_date_color' ];
124 $cff_date_styles = 'style="';
125 if ( !empty($cff_date_size) && $cff_date_size != 'inherit' ) $cff_date_styles .= 'font-size:' . $cff_date_size . 'px; ';
126 if ( !empty($cff_date_weight) && $cff_date_weight != 'inherit' ) $cff_date_styles .= 'font-weight:' . $cff_date_weight . '; ';
127 if ( !empty($cff_date_color) ) $cff_date_styles .= 'color:#' . $cff_date_color . ';';
128 $cff_date_styles .= '"';
129
130 //Link to Facebook
131 $cff_link_size = $options[ 'cff_link_size' ];
132 $cff_link_weight = $options[ 'cff_link_weight' ];
133 $cff_link_color = $options[ 'cff_link_color' ];
134 $cff_link_styles = 'style="';
135 if ( !empty($cff_link_size) && $cff_link_size != 'inherit' ) $cff_link_styles .= 'font-size:' . $cff_link_size . 'px; ';
136 if ( !empty($cff_link_weight) && $cff_link_weight != 'inherit' ) $cff_link_styles .= 'font-weight:' . $cff_link_weight . '; ';
137 if ( !empty($cff_link_color) ) $cff_link_styles .= 'color:#' . $cff_link_color . ';';
138 $cff_link_styles .= '"';
139
140
141 /********** MISC **********/
142
143 //Like Box styles
144 $cff_likebox_bg_color = $options[ 'cff_likebox_bg_color' ];
145 $cff_likebox_styles = 'style="';
146 if ( !empty($cff_likebox_bg_color) ) $cff_likebox_styles .= 'background-color:#' . $cff_likebox_bg_color . '; margin-left: 0; ';
147 $cff_likebox_styles .= '"';
148
149
150
151
152 //Pass in shortcode attrbutes
153 $atts = shortcode_atts(
154 array(
155 'id' => get_option('cff_page_id'),
156 'show' => get_option('cff_num_show'),
157 'titlelength' => get_option('cff_title_length'),
158 'bodylength' => get_option('cff_body_length')
159 ), $atts);
160
161 //Text limits
162 $title_limit = $atts['titlelength'];
163 $body_limit = $atts['bodylength'];
164
165 //Assign the Access Token and Page ID variables
166 $access_token = get_option('cff_access_token');
167 $page_id = $atts['id'];
168
169 //Get show posts attribute. If not set then default to 10.
170 $show_posts = $atts['show'];
171 if ( $show_posts == 0 || $show_posts == undefined ) $show_posts = 10;
172 //Check whether the Access Token is present and valid
173 if ($access_token == '') {
174 echo 'Please enter a valid Access Token. You can do this in the Custom Facebook Feed plugin settings.<br /><br />';
175 return false;
176 }
177 //Check whether a Page ID has been defined
178 if ($page_id == '') {
179 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 />";
180 return false;
181 }
182
183 //Get the contents of the Facebook page
184 $json_object = fetchUrl('https://graph.facebook.com/' . $page_id . '/posts?access_token=' . $access_token);
185 //Interpret data with JSON
186 $FBdata = json_decode($json_object);
187 //Set like box variable
188 $like_box = '<div class="cff-likebox" ' . $cff_likebox_styles . '><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like-box href="http://www.facebook.com/' . $page_id . '" width="300" show_faces="false" stream="false" header="true"></fb:like-box></div>';
189
190
191
192 //***START FEED***
193 //Create HTML
194 $content = '<div id="cff" class="';
195 if ( !empty($cff_feed_height) ) $content .= 'fixed-height ';
196 $content .= '"' . $cff_feed_styles . '>';
197
198
199 //Add like box to top of feed
200 if ($cff_like_box_position == 'top' && $cff_show_like_box) $content .= $like_box;
201 //Limit var
202 $i = 0;
203
204 foreach ($FBdata->data as $news )
205 {
206 //Explode News and Page ID's into 2 values
207 $PostID = explode("_", $news->id);
208 //Check whether it's a status (author comment or like)
209 if ( ( $news->type == 'status' && !empty($news->message) ) || $news->type !== 'status' ) {
210 //If it isn't then create the post
211 //Only create posts for the amount of posts specified
212 if ( $i == $show_posts ) break;
213 $i++;
214
215
216 //********************************//
217 //***COMPILE SECTION VARIABLES***//
218 //********************************//
219
220 //POST TEXT
221 $cff_post_text = '<' . $cff_title_format . ' ' . $cff_title_styles . '">';
222 if (!empty($news->story)) {
223 $story_text = $news->story;
224 if (!empty($title_limit)) {
225 if (strlen($story_text) > $title_limit) $story_text = substr($story_text, 0, $title_limit) . '...';
226 }
227 $cff_post_text .= cff_make_clickable($story_text) . ' ';
228 }
229 if (!empty($news->message)) {
230 $message_text = $news->message;
231 if (!empty($title_limit)) {
232 if (strlen($message_text) > $title_limit) $message_text = substr($message_text, 0, $title_limit) . '...';
233 }
234 $cff_post_text .= cff_make_clickable($message_text) . ' ';
235 }
236 if (!empty($news->name) && empty($news->story)) {
237 $name_text = $news->name;
238 if (!empty($title_limit)) {
239 if (strlen($name_text) > $title_limit) $name_text = substr($name_text, 0, $title_limit) . '...';
240 }
241 $cff_post_text .= cff_make_clickable($name_text);
242 }
243 $cff_post_text .= '</' . $cff_title_format . '>';
244
245 //DESCRIPTION
246 $cff_description = '';
247 if (!empty($news->description)) {
248 $description_text = $news->description;
249 if (!empty($body_limit)) {
250 if (strlen($description_text) > $body_limit) $description_text = substr($description_text, 0, $body_limit) . '...';
251 }
252 $cff_description .= '<p '.$cff_body_styles.'>' . cff_make_clickable($description_text) . '</p>';
253 }
254
255 //LINK
256 $cff_shared_link = '';
257 //Display shared link
258 if ($news->type == 'link') {
259 //Display link name and description
260 if (!empty($news->description)) {
261 $cff_shared_link .= '<p class="text-link no-image"><a href="'.$news->link.'" '.$target.'>'. '<b>' . $news->name . '</b></a></p>';
262 }
263 }
264
265 //DATE
266 $cff_date = '<p class="cff-date" '.$cff_date_styles.'>Posted '. cff_timeSince(strtotime($news->created_time)) . ' ago</p>';
267
268 //EVENT
269 $cff_event = '';
270 if ($cff_show_event_title || $cff_show_event_details) {
271 //Check for media
272 if ($news->type == 'link') {
273 $story = $news->story;
274 //Check whether it's an event
275 $created_event = 'created an event.';
276 $shared_event = 'shared an event.';
277 $created_event = stripos($story, $created_event);
278 $shared_event = stripos($story, $shared_event);
279 if ( $created_event || $shared_event ){
280 //Get the event object
281 $eventID = $PostID[1];
282 if ( $shared_event ) {
283 //Get the event id from the event URL. eg: http://www.facebook.com/events/123451234512345/
284 $event_url = parse_url($news->link);
285 $url_parts = explode('/', $event_url['path']);
286 //Get the id from the parts
287 $eventID = $url_parts[count($url_parts)-2];
288 }
289 //Get the contents of the event using the WP HTTP API
290 $event_json = fetchUrl('https://graph.facebook.com/'.$eventID.'?access_token=' . $access_token);
291 //Interpret data with JSON
292 $event_object = json_decode($event_json);
293
294 //EVENT
295 //Display the event details
296 $cff_event = '<div class="details">';
297 //Show event title
298 if ($cff_show_event_title && !empty($event_object->name)) $cff_event .= '<' . $cff_event_title_format . ' ' . $cff_event_title_styles . '>' . $event_object->name . '</' . $cff_event_title_format . '>';
299 //Show event details
300 if ($cff_show_event_details){
301 if (!empty($event_object->location)) $cff_event .= '<p ' . $cff_event_details_styles . '>Where: ' . $event_object->location . '</p>';
302 if (!empty($event_object->start_time)) $cff_event .= '<p ' . $cff_event_details_styles . '>When: ' . date("F j, Y, g:i a", strtotime($event_object->start_time)) . '</p>';
303 if (!empty($event_object->description)){
304 $description = $event_object->description;
305 if (!empty($body_limit)) {
306 if (strlen($description) > $body_limit) $description = substr($description, 0, $body_limit) . '...';
307 }
308 $cff_event .= '<p ' . $cff_event_details_styles . '>' . cff_make_clickable($description) . '</p>';
309 }
310 }
311 $cff_event .= '</div><!-- end .details -->';
312 }
313 }
314 }
315
316
317 //LINK
318 //Display the link to the Facebook post or external link
319 $cff_link = '';
320 if (!empty($news->link)) {
321 $link = $news->link;
322 //Check whether it links to facebook or somewhere else
323 $facebook_str = 'facebook.com';
324 if(stripos($link, $facebook_str) !== false) {
325 $link_text = 'View on Facebook';
326 } else {
327 $link_text = 'View Link';
328 }
329 $cff_link = '<div class="meta-wrap"><a class="cff-viewpost" href="' . $link . '" title="' . $link_text . '" ' . $target . ' ' . $cff_link_styles . '>' . $link_text . '</a></div><!-- end .meta-wrap -->';
330 }
331
332
333
334 //**************************//
335 //***CREATE THE POST HTML***//
336 //**************************//
337
338 //Start the container
339 $content .= '<div class="cff-item ';
340 if ($news->type == 'link') $content .= 'link-item';
341 $content .= '">';
342
343
344
345 //POST TEXT
346 if($cff_show_text) $content .= $cff_post_text;
347
348 //DESCRIPTION
349 if($cff_show_desc) $content .= $cff_description;
350
351 //LINK
352 if($cff_show_desc) $content .= $cff_shared_link;
353
354 //EVENT
355 if($cff_show_event_title || $cff_show_event_details) $content .= $cff_event;
356
357 //DATE
358 if($cff_show_date) $content .= $cff_date;
359
360 //LINK
361 if($cff_show_link) $content .= $cff_link;
362
363
364 //End the post item
365 $content .= '</div><div class="clear"></div> <!-- end .cff-item -->';
366
367
368
369
370 } // End status check
371
372 } // End the loop
373
374 //Add the Like Box
375 if ($cff_like_box_position == 'bottom' && $cff_show_like_box) $content .= $like_box;
376
377 //End the feed
378 $content .= '</div><div class="clear"></div> <!-- end .Custom Facebook Feed -->';
379
380 //Return our feed HTML to display
381 return $content;
382 }
383
384 //Get JSON object of feed data
385 function fetchUrl($url){
386 //Can we use cURL?
387 if(is_callable('curl_init')){
388 $ch = curl_init();
389 curl_setopt($ch, CURLOPT_URL, $url);
390 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
391 curl_setopt($ch, CURLOPT_TIMEOUT, 20);
392 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
393 $feedData = curl_exec($ch);
394 curl_close($ch);
395 //If not then use file_get_contents
396 } elseif ( ini_get('allow_url_fopen') == 1 || ini_get('allow_url_fopen') === TRUE ) {
397 $feedData = @file_get_contents($url);
398 //Or else use the WP HTTP API
399 } else {
400 if( !class_exists( 'WP_Http' ) ) include_once( ABSPATH . WPINC. '/class-http.php' );
401 $request = new WP_Http;
402 $result = $request->request($url);
403 $feedData = $result['body'];
404 }
405
406 return $feedData;
407 }
408
409
410 //***FUNCTIONS***
411
412 //Make links in text clickable
413 function cff_make_url_clickable($matches) {
414 $target = 'target="_blank"';
415 $ret = '';
416 $url = $matches[2];
417
418 if ( empty($url) )
419 return $matches[0];
420 // removed trailing [.,;:] from URL
421 if ( in_array(substr($url, -1), array('.', ',', ';', ':')) === true ) {
422 $ret = substr($url, -1);
423 $url = substr($url, 0, strlen($url)-1);
424 }
425 return $matches[1] . "<a href=\"$url\" rel=\"nofollow\" ".$target.">$url</a>" . $ret;
426 }
427 function cff_make_web_ftp_clickable($matches) {
428 $target = 'target="_blank"';
429 $ret = '';
430 $dest = $matches[2];
431 $dest = 'http://' . $dest;
432
433 if ( empty($dest) )
434 return $matches[0];
435 // removed trailing [,;:] from URL
436 if ( in_array(substr($dest, -1), array('.', ',', ';', ':')) === true ) {
437 $ret = substr($dest, -1);
438 $dest = substr($dest, 0, strlen($dest)-1);
439 }
440 return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\" ".$target.">$dest</a>" . $ret;
441 }
442 function cff_make_email_clickable($matches) {
443 $email = $matches[2] . '@' . $matches[3];
444 return $matches[1] . "<a href=\"mailto:$email\">$email</a>";
445 }
446 function cff_make_clickable($ret) {
447 $ret = ' ' . $ret;
448 // in testing, using arrays here was found to be faster
449 $ret = preg_replace_callback('#([\s>])([\w]+?://[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', 'cff_make_url_clickable', $ret);
450 $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', 'cff_make_web_ftp_clickable', $ret);
451 $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', 'cff_make_email_clickable', $ret);
452
453 // this one is not in an array because we need it to run last, for cleanup of accidental links within links
454 $ret = preg_replace("#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i", "$1$3</a>", $ret);
455 $ret = trim($ret);
456 return $ret;
457 }
458
459
460 //Time stamp function
461 function cff_timeSince($original) {
462 // Array of time period
463 $chunks = array(
464 array(60 * 60 * 24 * 365 , 'year'),
465 array(60 * 60 * 24 * 30 , 'month'),
466 array(60 * 60 * 24 * 7, 'week'),
467 array(60 * 60 * 24 , 'day'),
468 array(60 * 60 , 'hour'),
469 array(60 , 'minute'),
470 );
471
472 // Current time
473 $today = time();
474 $since = $today - $original;
475
476 // $j saves performing the count function each time around the loop
477 for ($i = 0, $j = count($chunks); $i < $j; $i++) {
478
479 $seconds = $chunks[$i][0];
480 $name = $chunks[$i][1];
481
482 // finding the biggest chunk (if the chunk fits, break)
483 if (($count = floor($since / $seconds)) != 0) {
484 break;
485 }
486 }
487
488 $print = ($count == 1) ? '1 '.$name : "$count {$name}s";
489
490 if ($i + 1 < $j) {
491 // now getting the second item
492 $seconds2 = $chunks[$i + 1][0];
493 $name2 = $chunks[$i + 1][1];
494
495 // add second item if it's greater than 0
496 if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0) {
497 $print .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s";
498 }
499 }
500 return $print;
501 }
502
503
504 //Enqueue stylesheet
505 add_action( 'wp_enqueue_scripts', 'cff_add_my_stylesheet' );
506 function cff_add_my_stylesheet() {
507 // Respects SSL, Style.css is relative to the current file
508 wp_register_style( 'cff', plugins_url('css/cff-style.css', __FILE__) );
509 wp_enqueue_style( 'cff' );
510 }
511
512
513 //Allows shortcodes in sidebar of theme
514 add_filter('widget_text', 'do_shortcode');
515
516
517 function cff_activate() {
518 $options = get_option('cff_style_settings');
519
520 //Show all parts of the feed by default on activation
521 $options[ 'cff_show_text' ] = true;
522 $options[ 'cff_show_desc' ] = true;
523 $options[ 'cff_show_date' ] = true;
524 $options[ 'cff_show_event_title' ] = true;
525 $options[ 'cff_show_event_details' ] = true;
526 $options[ 'cff_show_link' ] = true;
527 $options[ 'cff_show_like_box' ] = true;
528
529 update_option( 'cff_style_settings', $options );
530 }
531 register_activation_hook( __FILE__, 'cff_activate' );
532
533
534 //Uninstall
535 function cff_uninstall()
536 {
537 if ( ! current_user_can( 'activate_plugins' ) )
538 return;
539 delete_option( 'cff_access_token' );
540 delete_option( 'cff_page_id' );
541 delete_option( 'cff_num_show' );
542 delete_option( 'cff_title_length' );
543 delete_option( 'cff_body_length' );
544 delete_option('cff_style_settings');
545 }
546 register_uninstall_hook( __FILE__, 'cff_uninstall' );
547
548
549 //Comment out the line below to view errors
550 error_reporting(0);
551 ?>