PluginProbe ʕ •ᴥ•ʔ
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress / 1.9.6
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress v1.9.6
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
1926 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.9.6
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_author' ]) $include_string .= 'author,';
37 if($options[ 'cff_show_text' ]) $include_string .= 'text,';
38 if($options[ 'cff_show_desc' ]) $include_string .= 'desc,';
39 if($options[ 'cff_show_shared_links' ]) $include_string .= 'sharedlinks,';
40 if($options[ 'cff_show_date' ]) $include_string .= 'date,';
41 if($options[ 'cff_show_media' ]) $include_string .= 'media,';
42 if($options[ 'cff_show_event_title' ]) $include_string .= 'eventtitle,';
43 if($options[ 'cff_show_event_details' ]) $include_string .= 'eventdetails,';
44 if($options[ 'cff_show_meta' ]) $include_string .= 'social,';
45 if($options[ 'cff_show_link' ]) $include_string .= 'link,';
46 if($options[ 'cff_show_like_box' ]) $include_string .= 'likebox,';
47 //Pass in shortcode attrbutes
48 $atts = shortcode_atts(
49 array(
50 'accesstoken' => trim( get_option('cff_access_token') ),
51 'id' => get_option('cff_page_id'),
52 'pagetype' => get_option('cff_page_type'),
53 'num' => get_option('cff_num_show'),
54 'limit' => get_option('cff_post_limit'),
55 'others' => '',
56 'showpostsby' => 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 'ajax' => get_option('cff_ajax'),
61 'width' => isset($options[ 'cff_feed_width' ]) ? $options[ 'cff_feed_width' ] : '',
62 'height' => isset($options[ 'cff_feed_height' ]) ? $options[ 'cff_feed_height' ] : '',
63 'padding' => isset($options[ 'cff_feed_padding' ]) ? $options[ 'cff_feed_padding' ] : '',
64 'bgcolor' => isset($options[ 'cff_bg_color' ]) ? $options[ 'cff_bg_color' ] : '',
65 'showauthor' => '',
66 'showauthornew' => isset($options[ 'cff_show_author' ]) ? $options[ 'cff_show_author' ] : '',
67 'class' => isset($options[ 'cff_class' ]) ? $options[ 'cff_class' ] : '',
68 'layout' => isset($options[ 'cff_preset_layout' ]) ? $options[ 'cff_preset_layout' ] : '',
69 'include' => $include_string,
70 'exclude' => '',
71 //Typography
72 'textformat' => isset($options[ 'cff_title_format' ]) ? $options[ 'cff_title_format' ] : '',
73 'textsize' => isset($options[ 'cff_title_size' ]) ? $options[ 'cff_title_size' ] : '',
74 'textweight' => isset($options[ 'cff_title_weight' ]) ? $options[ 'cff_title_weight' ] : '',
75 'textcolor' => isset($options[ 'cff_title_color' ]) ? $options[ 'cff_title_color' ] : '',
76 'textlinkcolor' => isset($options[ 'cff_posttext_link_color' ]) ? $options[ 'cff_posttext_link_color' ] : '',
77 'textlink' => isset($options[ 'cff_title_link' ]) ? $options[ 'cff_title_link' ] : '',
78 'posttags' => isset($options[ 'cff_post_tags' ]) ? $options[ 'cff_post_tags' ] : '',
79 //Description
80 'descsize' => isset($options[ 'cff_body_size' ]) ? $options[ 'cff_body_size' ] : '',
81 'descweight' => isset($options[ 'cff_body_weight' ]) ? $options[ 'cff_body_weight' ] : '',
82 'desccolor' => isset($options[ 'cff_body_color' ]) ? $options[ 'cff_body_color' ] : '',
83 'linktitleformat' => isset($options[ 'cff_link_title_format' ]) ? $options[ 'cff_link_title_format' ] : '',
84 'linktitlesize' => isset($options[ 'cff_link_title_size' ]) ? $options[ 'cff_link_title_size' ] : '',
85 'linktitlecolor' => isset($options[ 'cff_link_title_color' ]) ? $options[ 'cff_link_title_color' ] : '',
86 'linkurlcolor' => isset($options[ 'cff_link_url_color' ]) ? $options[ 'cff_link_url_color' ] : '',
87 'linkbgcolor' => isset($options[ 'cff_link_bg_color' ]) ? $options[ 'cff_link_bg_color' ] : '',
88 'linkbordercolor' => isset($options[ 'cff_link_border_color' ]) ? $options[ 'cff_link_border_color' ] : '',
89 'disablelinkbox' => isset($options[ 'cff_disable_link_box' ]) ? $options[ 'cff_disable_link_box' ] : '',
90
91 //Author
92 'authorsize' => isset($options[ 'cff_author_size' ]) ? $options[ 'cff_author_size' ] : '',
93 'authorcolor' => isset($options[ 'cff_author_color' ]) ? $options[ 'cff_author_color' ] : '',
94
95 //Event title
96 'eventtitleformat' => isset($options[ 'cff_event_title_format' ]) ? $options[ 'cff_event_title_format' ] : '',
97 'eventtitlesize' => isset($options[ 'cff_event_title_size' ]) ? $options[ 'cff_event_title_size' ] : '',
98 'eventtitleweight' => isset($options[ 'cff_event_title_weight' ]) ? $options[ 'cff_event_title_weight' ] : '',
99 'eventtitlecolor' => isset($options[ 'cff_event_title_color' ]) ? $options[ 'cff_event_title_color' ] : '',
100 'eventtitlelink' => isset($options[ 'cff_event_title_link' ]) ? $options[ 'cff_event_title_link' ] : '',
101 //Event date
102 'eventdatesize' => isset($options[ 'cff_event_date_size' ]) ? $options[ 'cff_event_date_size' ] : '',
103 'eventdateweight' => isset($options[ 'cff_event_date_weight' ]) ? $options[ 'cff_event_date_weight' ] : '',
104 'eventdatecolor' => isset($options[ 'cff_event_date_color' ]) ? $options[ 'cff_event_date_color' ] : '',
105 'eventdatepos' => isset($options[ 'cff_event_date_position' ]) ? $options[ 'cff_event_date_position' ] : '',
106 'eventdateformat' => isset($options[ 'cff_event_date_formatting' ]) ? $options[ 'cff_event_date_formatting' ] : '',
107 'eventdatecustom' => isset($options[ 'cff_event_date_custom' ]) ? $options[ 'cff_event_date_custom' ] : '',
108 //Event details
109 'eventdetailssize' => isset($options[ 'cff_event_details_size' ]) ? $options[ 'cff_event_details_size' ] : '',
110 'eventdetailsweight' => isset($options[ 'cff_event_details_weight' ]) ? $options[ 'cff_event_details_weight' ] : '',
111 'eventdetailscolor' => isset($options[ 'cff_event_details_color' ]) ? $options[ 'cff_event_details_color' ] : '',
112 'eventlinkcolor' => isset($options[ 'cff_event_link_color' ]) ? $options[ 'cff_event_link_color' ] : '',
113 //Date
114 'datepos' => isset($options[ 'cff_date_position' ]) ? $options[ 'cff_date_position' ] : '',
115 'datesize' => isset($options[ 'cff_date_size' ]) ? $options[ 'cff_date_size' ] : '',
116 'dateweight' => isset($options[ 'cff_date_weight' ]) ? $options[ 'cff_date_weight' ] : '',
117 'datecolor' => isset($options[ 'cff_date_color' ]) ? $options[ 'cff_date_color' ] : '',
118 'dateformat' => isset($options[ 'cff_date_formatting' ]) ? $options[ 'cff_date_formatting' ] : '',
119 'datecustom' => isset($options[ 'cff_date_custom' ]) ? $options[ 'cff_date_custom' ] : '',
120 'timezone' => isset($options[ 'cff_timezone' ]) ? $options[ 'cff_timezone' ] : 'America/Chicago',
121
122 //Link to Facebook
123 'linksize' => isset($options[ 'cff_link_size' ]) ? $options[ 'cff_link_size' ] : '',
124 'linkweight' => isset($options[ 'cff_link_weight' ]) ? $options[ 'cff_link_weight' ] : '',
125 'linkcolor' => isset($options[ 'cff_link_color' ]) ? $options[ 'cff_link_color' ] : '',
126 'viewlinktext' => isset($options[ 'cff_view_link_text' ]) ? $options[ 'cff_view_link_text' ] : '',
127 'linktotimeline' => isset($options[ 'cff_link_to_timeline' ]) ? $options[ 'cff_link_to_timeline' ] : '',
128 //Social
129 'iconstyle' => isset($options[ 'cff_icon_style' ]) ? $options[ 'cff_icon_style' ] : '',
130 'socialtextcolor' => isset($options[ 'cff_meta_text_color' ]) ? $options[ 'cff_meta_text_color' ] : '',
131 'socialbgcolor' => isset($options[ 'cff_meta_bg_color' ]) ? $options[ 'cff_meta_bg_color' ] : '',
132 //Misc
133 'textlength' => get_option('cff_title_length'),
134 'desclength' => get_option('cff_body_length'),
135 'likeboxpos' => isset($options[ 'cff_like_box_position' ]) ? $options[ 'cff_like_box_position' ] : '',
136 'likeboxoutside' => isset($options[ 'cff_like_box_outside' ]) ? $options[ 'cff_like_box_outside' ] : '',
137 'likeboxcolor' => isset($options[ 'cff_likebox_bg_color' ]) ? $options[ 'cff_likebox_bg_color' ] : '',
138 'likeboxtextcolor' => isset($options[ 'cff_like_box_text_color' ]) ? $options[ 'cff_like_box_text_color' ] : '',
139 'likeboxwidth' => isset($options[ 'cff_likebox_width' ]) ? $options[ 'cff_likebox_width' ] : '',
140 'likeboxheight' => isset($options[ 'cff_likebox_height' ]) ? $options[ 'cff_likebox_height' ] : '',
141 'likeboxfaces' => isset($options[ 'cff_like_box_faces' ]) ? $options[ 'cff_like_box_faces' ] : '',
142 'likeboxborder' => isset($options[ 'cff_like_box_border' ]) ? $options[ 'cff_like_box_border' ] : '',
143
144 //Page Header
145 'showheader' => isset($options[ 'cff_show_header' ]) ? $options[ 'cff_show_header' ] : '',
146 'headeroutside' => isset($options[ 'cff_header_outside' ]) ? $options[ 'cff_header_outside' ] : '',
147 'headertext' => isset($options[ 'cff_header_text' ]) ? $options[ 'cff_header_text' ] : '',
148 'headerbg' => isset($options[ 'cff_header_bg_color' ]) ? $options[ 'cff_header_bg_color' ] : '',
149 'headerpadding' => isset($options[ 'cff_header_padding' ]) ? $options[ 'cff_header_padding' ] : '',
150 'headertextsize' => isset($options[ 'cff_header_text_size' ]) ? $options[ 'cff_header_text_size' ] : '',
151 'headertextweight' => isset($options[ 'cff_header_text_weight' ]) ? $options[ 'cff_header_text_weight' ] : '',
152 'headertextcolor' => isset($options[ 'cff_header_text_color' ]) ? $options[ 'cff_header_text_color' ] : '',
153 'headericon' => isset($options[ 'cff_header_icon' ]) ? $options[ 'cff_header_icon' ] : '',
154 'headericoncolor' => isset($options[ 'cff_header_icon_color' ]) ? $options[ 'cff_header_icon_color' ] : '',
155 'headericonsize' => isset($options[ 'cff_header_icon_size' ]) ? $options[ 'cff_header_icon_size' ] : '',
156
157 'videoheight' => isset($options[ 'cff_video_height' ]) ? $options[ 'cff_video_height' ] : '',
158 'videoaction' => isset($options[ 'cff_video_action' ]) ? $options[ 'cff_video_action' ] : '',
159 'sepcolor' => isset($options[ 'cff_sep_color' ]) ? $options[ 'cff_sep_color' ] : '',
160 'sepsize' => isset($options[ 'cff_sep_size' ]) ? $options[ 'cff_sep_size' ] : '',
161
162 //Translate
163 'seemoretext' => isset($options[ 'cff_see_more_text' ]) ? $options[ 'cff_see_more_text' ] : '',
164 'seelesstext' => isset($options[ 'cff_see_less_text' ]) ? $options[ 'cff_see_less_text' ] : '',
165 'facebooklinktext' => isset($options[ 'cff_facebook_link_text' ]) ? $options[ 'cff_facebook_link_text' ] : '',
166 'photostext' => isset($options[ 'cff_translate_photos_text' ]) ? $options[ 'cff_translate_photos_text' ] : ''
167 ), $atts);
168 /********** GENERAL **********/
169 $cff_page_type = $atts[ 'pagetype' ];
170 ($cff_page_type == 'group') ? $cff_is_group = true : $cff_is_group = false;
171
172 $cff_feed_width = $atts['width'];
173 $cff_feed_height = $atts[ 'height' ];
174 $cff_feed_padding = $atts[ 'padding' ];
175 $cff_bg_color = $atts[ 'bgcolor' ];
176 $cff_show_author = $atts[ 'showauthornew' ];
177 $cff_cache_time = $atts[ 'cachetime' ];
178 $cff_locale = $atts[ 'locale' ];
179 if ( empty($cff_locale) || !isset($cff_locale) || $cff_locale == '' ) $cff_locale = 'en_US';
180 if (!isset($cff_cache_time)) $cff_cache_time = 0;
181 $cff_cache_time_unit = $atts[ 'cacheunit' ];
182 $cff_class = $atts['class'];
183 //Compile feed styles
184 $cff_feed_styles = 'style="';
185 if ( !empty($cff_feed_width) ) $cff_feed_styles .= 'width:' . $cff_feed_width . '; ';
186 if ( !empty($cff_feed_height) ) $cff_feed_styles .= 'height:' . $cff_feed_height . '; ';
187 if ( !empty($cff_feed_padding) ) $cff_feed_styles .= 'padding:' . $cff_feed_padding . '; ';
188 if ( !empty($cff_bg_color) ) $cff_feed_styles .= 'background-color:#' . str_replace('#', '', $cff_bg_color) . '; ';
189 $cff_feed_styles .= '"';
190 //Like box
191 $cff_like_box_position = $atts[ 'likeboxpos' ];
192 $cff_like_box_outside = $atts[ 'likeboxoutside' ];
193 //Open links in new window?
194 $target = 'target="_blank"';
195 /********** POST TYPES **********/
196 $cff_show_links_type = true;
197 $cff_show_event_type = true;
198 $cff_show_video_type = true;
199 $cff_show_photos_type = true;
200 $cff_show_status_type = true;
201 $cff_events_only = false;
202 //Are we showing ONLY events?
203 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;
204 /********** LAYOUT **********/
205 $cff_includes = $atts[ 'include' ];
206 //Look for non-plural version of string in the types string in case user specifies singular in shortcode
207 $cff_show_author = false;
208 $cff_show_text = false;
209 $cff_show_desc = false;
210 $cff_show_shared_links = false;
211 $cff_show_date = false;
212 $cff_show_media = false;
213 $cff_show_event_title = false;
214 $cff_show_event_details = false;
215 $cff_show_meta = false;
216 $cff_show_link = false;
217 $cff_show_like_box = false;
218 if ( stripos($cff_includes, 'author') !== false ) $cff_show_author = true;
219 if ( stripos($cff_includes, 'text') !== false ) $cff_show_text = true;
220 if ( stripos($cff_includes, 'desc') !== false ) $cff_show_desc = true;
221 if ( stripos($cff_includes, 'sharedlink') !== false ) $cff_show_shared_links = true;
222 if ( stripos($cff_includes, 'date') !== false ) $cff_show_date = true;
223 if ( stripos($cff_includes, 'media') !== false ) $cff_show_media = true;
224 if ( stripos($cff_includes, 'eventtitle') !== false ) $cff_show_event_title = true;
225 if ( stripos($cff_includes, 'eventdetail') !== false ) $cff_show_event_details = true;
226 if ( stripos($cff_includes, 'social') !== false ) $cff_show_meta = true;
227 if ( stripos($cff_includes, ',link') !== false ) $cff_show_link = true; //comma used to separate it from 'sharedlinks' - which also contains 'link' string
228 if ( stripos($cff_includes, 'like') !== false ) $cff_show_like_box = true;
229
230
231 //Exclude string
232 $cff_excludes = $atts[ 'exclude' ];
233 //Look for non-plural version of string in the types string in case user specifies singular in shortcode
234 if ( stripos($cff_excludes, 'author') !== false ) $cff_show_author = false;
235 if ( stripos($cff_excludes, 'text') !== false ) $cff_show_text = false;
236 if ( stripos($cff_excludes, 'desc') !== false ) $cff_show_desc = false;
237 if ( stripos($cff_excludes, 'sharedlink') !== false ) $cff_show_shared_links = false;
238 if ( stripos($cff_excludes, 'date') !== false ) $cff_show_date = false;
239 if ( stripos($cff_excludes, 'media') !== false ) $cff_show_media = false;
240 if ( stripos($cff_excludes, 'eventtitle') !== false ) $cff_show_event_title = false;
241 if ( stripos($cff_excludes, 'eventdetail') !== false ) $cff_show_event_details = false;
242 if ( stripos($cff_excludes, 'social') !== false ) $cff_show_meta = false;
243 if ( stripos($cff_excludes, ',link') !== false ) $cff_show_link = false; //comma used to separate it from 'sharedlinks' - which also contains 'link' string
244 if ( stripos($cff_excludes, 'like') !== false ) $cff_show_like_box = false;
245
246
247 //Set free version to thumb layout by default as layout option not available on settings page
248 $cff_preset_layout = 'thumb';
249
250 //If the old shortcode option 'showauthor' is being used then apply it
251 $cff_show_author_old = $atts[ 'showauthor' ];
252 if( $cff_show_author_old == 'false' ) $cff_show_author = false;
253 if( $cff_show_author_old == 'true' ) $cff_show_author = true;
254
255
256 /********** META **********/
257 $cff_icon_style = $atts[ 'iconstyle' ];
258 $cff_meta_text_color = $atts[ 'socialtextcolor' ];
259 $cff_meta_bg_color = $atts[ 'socialbgcolor' ];
260 $cff_meta_styles = 'style="';
261 if ( !empty($cff_meta_text_color) ) $cff_meta_styles .= 'color:#' . str_replace('#', '', $cff_meta_text_color) . ';';
262 if ( !empty($cff_meta_bg_color) ) $cff_meta_styles .= 'background-color:#' . str_replace('#', '', $cff_meta_bg_color) . ';';
263 $cff_meta_styles .= '"';
264 $cff_nocomments_text = isset($options[ 'cff_nocomments_text' ]) ? $options[ 'cff_nocomments_text' ] : '';
265 $cff_hide_comments = isset($options[ 'cff_hide_comments' ]) ? $options[ 'cff_hide_comments' ] : '';
266 if (!isset($cff_nocomments_text) || empty($cff_nocomments_text)) $cff_hide_comments = true;
267 /********** TYPOGRAPHY **********/
268 //See More text
269 $cff_see_more_text = $atts[ 'seemoretext' ];
270 $cff_see_less_text = $atts[ 'seelesstext' ];
271 //See Less text
272 //Title
273 $cff_title_format = $atts[ 'textformat' ];
274 if (empty($cff_title_format)) $cff_title_format = 'p';
275 $cff_title_size = $atts[ 'textsize' ];
276 $cff_title_weight = $atts[ 'textweight' ];
277 $cff_title_color = $atts[ 'textcolor' ];
278 $cff_title_styles = 'style="';
279 if ( !empty($cff_title_size) && $cff_title_size != 'inherit' ) $cff_title_styles .= 'font-size:' . $cff_title_size . 'px; ';
280 if ( !empty($cff_title_weight) && $cff_title_weight != 'inherit' ) $cff_title_styles .= 'font-weight:' . $cff_title_weight . '; ';
281 if ( !empty($cff_title_color) ) $cff_title_styles .= 'color:#' . str_replace('#', '', $cff_title_color) . ';';
282 $cff_title_styles .= '"';
283 $cff_title_link = $atts[ 'textlink' ];
284
285 ( $cff_title_link == 'on' || $cff_title_link == 'true' || $cff_title_link == true ) ? $cff_title_link = true : $cff_title_link = false;
286 if( $atts[ 'textlink' ] == 'false' ) $cff_title_link = false;
287
288 //Author
289 $cff_author_size = $atts[ 'authorsize' ];
290 $cff_author_color = $atts[ 'authorcolor' ];
291 $cff_author_styles = 'style="';
292 if ( !empty($cff_author_size) && $cff_author_size != 'inherit' ) $cff_author_styles .= 'font-size:' . $cff_author_size . 'px; ';
293 if ( !empty($cff_author_color) ) $cff_author_styles .= 'color:#' . str_replace('#', '', $cff_author_color) . ';';
294 $cff_author_styles .= '"';
295
296 //Description
297 $cff_body_size = $atts[ 'descsize' ];
298 $cff_body_weight = $atts[ 'descweight' ];
299 $cff_body_color = $atts[ 'desccolor' ];
300 $cff_body_styles = 'style="';
301 if ( !empty($cff_body_size) && $cff_body_size != 'inherit' ) $cff_body_styles .= 'font-size:' . $cff_body_size . 'px; ';
302 if ( !empty($cff_body_weight) && $cff_body_weight != 'inherit' ) $cff_body_styles .= 'font-weight:' . $cff_body_weight . '; ';
303 if ( !empty($cff_body_color) ) $cff_body_styles .= 'color:#' . str_replace('#', '', $cff_body_color) . ';';
304 $cff_body_styles .= '"';
305
306 //Shared link title
307 $cff_link_title_format = $atts[ 'linktitleformat' ];
308 if (empty($cff_link_title_format)) $cff_link_title_format = 'p';
309 $cff_link_title_size = $atts[ 'linktitlesize' ];
310 $cff_link_title_color = $atts[ 'linktitlecolor' ];
311 $cff_link_url_color = $atts[ 'linkurlcolor' ];
312
313 $cff_link_title_styles = 'style="';
314 if ( !empty($cff_link_title_size) && $cff_link_title_size != 'inherit' ) $cff_link_title_styles .= 'font-size:' . $cff_link_title_size . 'px;';
315 $cff_link_title_styles .= '"';
316
317 //Shared link box
318 $cff_link_bg_color = $atts[ 'linkbgcolor' ];
319 $cff_link_border_color = $atts[ 'linkbordercolor' ];
320 $cff_disable_link_box = $atts['disablelinkbox'];
321 ($cff_disable_link_box == 'true' || $cff_disable_link_box == 'on') ? $cff_disable_link_box = true : $cff_disable_link_box = false;
322
323 $cff_link_box_styles = 'style="';
324 if ( !empty($cff_link_border_color) ) $cff_link_box_styles .= 'border: 1px solid #' . str_replace('#', '', $cff_link_border_color) . '; ';
325 if ( !empty($cff_link_bg_color) ) $cff_link_box_styles .= 'background-color: #' . str_replace('#', '', $cff_link_bg_color) . ';';
326 $cff_link_box_styles .= '"';
327
328 //Event Title
329 $cff_event_title_format = $atts[ 'eventtitleformat' ];
330 if (empty($cff_event_title_format)) $cff_event_title_format = 'p';
331 $cff_event_title_size = $atts[ 'eventtitlesize' ];
332 $cff_event_title_weight = $atts[ 'eventtitleweight' ];
333 $cff_event_title_color = $atts[ 'eventtitlecolor' ];
334 $cff_event_title_styles = 'style="';
335 if ( !empty($cff_event_title_size) && $cff_event_title_size != 'inherit' ) $cff_event_title_styles .= 'font-size:' . $cff_event_title_size . 'px; ';
336 if ( !empty($cff_event_title_weight) && $cff_event_title_weight != 'inherit' ) $cff_event_title_styles .= 'font-weight:' . $cff_event_title_weight . '; ';
337 if ( !empty($cff_event_title_color) ) $cff_event_title_styles .= 'color:#' . str_replace('#', '', $cff_event_title_color) . ';';
338 $cff_event_title_styles .= '"';
339 $cff_event_title_link = $atts[ 'eventtitlelink' ];
340 //Event Date
341 $cff_event_date_size = $atts[ 'eventdatesize' ];
342 $cff_event_date_weight = $atts[ 'eventdateweight' ];
343 $cff_event_date_color = $atts[ 'eventdatecolor' ];
344 $cff_event_date_position = $atts[ 'eventdatepos' ];
345 $cff_event_date_formatting = $atts[ 'eventdateformat' ];
346 $cff_event_date_custom = $atts[ 'eventdatecustom' ];
347 $cff_event_date_styles = 'style="';
348 if ( !empty($cff_event_date_size) && $cff_event_date_size != 'inherit' ) $cff_event_date_styles .= 'font-size:' . $cff_event_date_size . 'px; ';
349 if ( !empty($cff_event_date_weight) && $cff_event_date_weight != 'inherit' ) $cff_event_date_styles .= 'font-weight:' . $cff_event_date_weight . '; ';
350 if ( !empty($cff_event_date_color) ) $cff_event_date_styles .= 'color:#' . str_replace('#', '', $cff_event_date_color) . ';';
351 $cff_event_date_styles .= '"';
352 //Event Details
353 $cff_event_details_size = $atts[ 'eventdetailssize' ];
354 $cff_event_details_weight = $atts[ 'eventdetailsweight' ];
355 $cff_event_details_color = $atts[ 'eventdetailscolor' ];
356 $cff_event_link_color = $atts[ 'eventlinkcolor' ];
357 $cff_event_details_styles = 'style="';
358 if ( !empty($cff_event_details_size) && $cff_event_details_size != 'inherit' ) $cff_event_details_styles .= 'font-size:' . $cff_event_details_size . 'px; ';
359 if ( !empty($cff_event_details_weight) && $cff_event_details_weight != 'inherit' ) $cff_event_details_styles .= 'font-weight:' . $cff_event_details_weight . '; ';
360 if ( !empty($cff_event_details_color) ) $cff_event_details_styles .= 'color:#' . str_replace('#', '', $cff_event_details_color) . ';';
361 $cff_event_details_styles .= '"';
362 //Date
363 $cff_date_position = $atts[ 'datepos' ];
364 if (!isset($cff_date_position)) $cff_date_position = 'below';
365 $cff_date_size = $atts[ 'datesize' ];
366 $cff_date_weight = $atts[ 'dateweight' ];
367 $cff_date_color = $atts[ 'datecolor' ];
368 $cff_date_styles = 'style="';
369 if ( !empty($cff_date_size) && $cff_date_size != 'inherit' ) $cff_date_styles .= 'font-size:' . $cff_date_size . 'px; ';
370 if ( !empty($cff_date_weight) && $cff_date_weight != 'inherit' ) $cff_date_styles .= 'font-weight:' . $cff_date_weight . '; ';
371 if ( !empty($cff_date_color) ) $cff_date_styles .= 'color:#' . str_replace('#', '', $cff_date_color) . ';';
372 $cff_date_styles .= '"';
373 $cff_date_before = isset($options[ 'cff_date_before' ]) ? $options[ 'cff_date_before' ] : '';
374 $cff_date_after = isset($options[ 'cff_date_after' ]) ? $options[ 'cff_date_after' ] : '';
375 //Set user's timezone based on setting
376 $cff_timezone = $atts['timezone'];
377 $cff_orig_timezone = date_default_timezone_get();
378 date_default_timezone_set($cff_timezone);
379 //Link to Facebook
380 $cff_link_size = $atts[ 'linksize' ];
381 $cff_link_weight = $atts[ 'linkweight' ];
382 $cff_link_color = $atts[ 'linkcolor' ];
383 $cff_link_styles = 'style="';
384 if ( !empty($cff_link_size) && $cff_link_size != 'inherit' ) $cff_link_styles .= 'font-size:' . $cff_link_size . 'px; ';
385 if ( !empty($cff_link_weight) && $cff_link_weight != 'inherit' ) $cff_link_styles .= 'font-weight:' . $cff_link_weight . '; ';
386 if ( !empty($cff_link_color) ) $cff_link_styles .= 'color:#' . str_replace('#', '', $cff_link_color) . ';';
387 $cff_link_styles .= '"';
388 $cff_facebook_link_text = $atts[ 'facebooklinktext' ];
389 $cff_view_link_text = $atts[ 'viewlinktext' ];
390 $cff_link_to_timeline = $atts[ 'linktotimeline' ];
391 /********** MISC **********/
392 //Like Box styles
393 $cff_likebox_bg_color = $atts[ 'likeboxcolor' ];
394
395 $cff_like_box_text_color = $atts[ 'likeboxtextcolor' ];
396 $cff_like_box_colorscheme = 'light';
397 if ($cff_like_box_text_color == 'white') $cff_like_box_colorscheme = 'dark';
398
399 $cff_likebox_width = $atts[ 'likeboxwidth' ];
400 $cff_likebox_height = $atts[ 'likeboxheight' ];
401 $cff_likebox_height = preg_replace('/px$/', '', $cff_likebox_height);
402
403 if ( !isset($cff_likebox_width) || empty($cff_likebox_width) || $cff_likebox_width == '' ) $cff_likebox_width = '100%';
404 $cff_like_box_faces = $atts[ 'likeboxfaces' ];
405 if ( !isset($cff_like_box_faces) || empty($cff_like_box_faces) ) $cff_like_box_faces = 'false';
406 $cff_like_box_border = $atts[ 'likeboxborder' ];
407 if ($cff_like_box_border) {
408 $cff_like_box_border = 'true';
409 } else {
410 $cff_like_box_border = 'false';
411 }
412
413 //Compile Like box styles
414 $cff_likebox_styles = 'style="width: ' . $cff_likebox_width . ';';
415 if ( !empty($cff_likebox_bg_color) ) $cff_likebox_styles .= ' background-color: #' . str_replace('#', '', $cff_likebox_bg_color) . ';';
416 if ( empty($cff_likebox_bg_color) && $cff_like_box_faces == 'false' ) $cff_likebox_styles .= ' margin-left: -10px;';
417 $cff_likebox_styles .= '"';
418
419 //Get feed header settings
420 $cff_header_bg_color = $atts['headerbg'];
421 $cff_header_padding = $atts['headerpadding'];
422 $cff_header_text_size = $atts['headertextsize'];
423 $cff_header_text_weight = $atts['headertextweight'];
424 $cff_header_text_color = $atts['headertextcolor'];
425
426 //Compile feed header styles
427 $cff_header_styles = 'style="';
428 if ( !empty($cff_header_bg_color) ) $cff_header_styles .= 'background-color: #' . str_replace('#', '', $cff_header_bg_color) . ';';
429 if ( !empty($cff_header_padding) ) $cff_header_styles .= ' padding: ' . $cff_header_padding . ';';
430 if ( !empty($cff_header_text_size) ) $cff_header_styles .= ' font-size: ' . $cff_header_text_size . 'px;';
431 if ( !empty($cff_header_text_weight) ) $cff_header_styles .= ' font-weight: ' . $cff_header_text_weight . ';';
432 if ( !empty($cff_header_text_color) ) $cff_header_styles .= ' color: #' . str_replace('#', '', $cff_header_text_color) . ';';
433 $cff_header_styles .= '"';
434
435 //Video
436 //Dimensions
437 $cff_video_width = 640;
438 $cff_video_height = $atts[ 'videoheight' ];
439
440 //Action
441 $cff_video_action = $atts[ 'videoaction' ];
442 //Separating Line
443 $cff_sep_color = $atts[ 'sepcolor' ];
444 if (empty($cff_sep_color)) $cff_sep_color = 'ddd';
445 $cff_sep_size = $atts[ 'sepsize' ];
446 //If empty then set a 0px border
447 if ( empty($cff_sep_size) || $cff_sep_size == '' ) {
448 $cff_sep_size = 0;
449 //Need to set a color otherwise the CSS is invalid
450 $cff_sep_color = 'fff';
451 }
452 //CFF item styles
453 $cff_item_styles = 'style="';
454 $cff_item_styles .= 'border-bottom: ' . $cff_sep_size . 'px solid #' . str_replace('#', '', $cff_sep_color) . '; ';
455 $cff_item_styles .= '"';
456
457 //Text limits
458 $title_limit = $atts['textlength'];
459 if (!isset($title_limit)) $title_limit = 9999;
460 $body_limit = $atts['desclength'];
461 //Assign the Access Token and Page ID variables
462 $access_token = $atts['accesstoken'];
463 $page_id = trim( $atts['id'] );
464
465 //If user pastes their full URL into the Page ID field then strip it out
466 $cff_facebook_string = 'facebook.com';
467 $cff_page_id_url_check = stripos($page_id, $cff_facebook_string);
468
469 if ( $cff_page_id_url_check ) {
470 //Remove trailing slash if exists
471 $page_id = preg_replace('{/$}', '', $page_id);
472 //Get last part of url
473 $page_id = substr( $page_id, strrpos( $page_id, '/' )+1 );
474 }
475
476 //If the Page ID contains a query string at the end then remove it
477 if ( stripos( $page_id, '?') !== false ) $page_id = substr($page_id, 0, strrpos($page_id, '?'));
478
479 //Get show posts attribute. If not set then default to 25
480 $show_posts = $atts['num'];
481 if (empty($show_posts)) $show_posts = 25;
482 if ( $show_posts == 0 || $show_posts == 'undefined' ) $show_posts = 25;
483 //If there's no Access Token then use the default
484 if ($access_token == '') $access_token = '1436737606570258|MGh1BX4_b_D9HzJtKe702cwMRPI';
485 //Check whether a Page ID has been defined
486 if ($page_id == '') {
487 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=YOUR_PAGE_ID_HERE].<br /><br />";
488 return false;
489 }
490
491
492 //Is it SSL?
493 $cff_ssl = '';
494 if (is_ssl()) $cff_ssl = '&return_ssl_resources=true';
495
496 //Use posts? or feed?
497 $old_others_option = get_option('cff_show_others'); //Use this to help depreciate the old option
498 $show_others = $atts['others'];
499 $show_posts_by = $atts['showpostsby'];
500 $graph_query = 'posts';
501 $cff_show_only_others = false;
502
503 //If 'others' shortcode option is used then it overrides any other option
504 if ($show_others || $old_others_option == 'on') {
505 //Show posts by everyone
506 if ( $old_others_option == 'on' || $show_others == 'on' || $show_others == 'true' || $show_others == true || $cff_is_group ) $graph_query = 'feed';
507
508 //Only show posts by me
509 if ( $show_others == 'false' ) $graph_query = 'posts';
510
511 } else {
512 //Else use the settings page option or the 'showpostsby' shortcode option
513
514 //Only show posts by me
515 if ( $show_posts_by == 'me' ) $graph_query = 'posts';
516
517 //Show posts by everyone
518 if ( $show_posts_by == 'others' || $cff_is_group ) $graph_query = 'feed';
519
520 //Show posts ONLY by others
521 if ( $show_posts_by == 'onlyothers' && !$cff_is_group ) {
522 $graph_query = 'feed';
523 $cff_show_only_others = true;
524 }
525
526 }
527
528
529 //If the limit isn't set then set it to be 5 more than the number of posts defined
530 if ( isset($atts['limit']) && $atts['limit'] !== '' ) {
531 $cff_post_limit = $atts['limit'];
532 } else {
533 $cff_post_limit = intval(intval($show_posts) + 7);
534 }
535
536
537 //Calculate the cache time in seconds
538 if($cff_cache_time_unit == 'minutes') $cff_cache_time_unit = 60;
539 if($cff_cache_time_unit == 'hours') $cff_cache_time_unit = 60*60;
540 if($cff_cache_time_unit == 'days') $cff_cache_time_unit = 60*60*24;
541 $cache_seconds = $cff_cache_time * $cff_cache_time_unit;
542
543 //Get like box vars
544 $cff_likebox_width = $atts[ 'likeboxwidth' ];
545 if ( !isset($cff_likebox_width) || empty($cff_likebox_width) || $cff_likebox_width == '' ) $cff_likebox_width = 300;
546 $cff_like_box_faces = $atts[ 'likeboxfaces' ];
547 if ( !isset($cff_like_box_faces) || empty($cff_like_box_faces) ) $cff_like_box_faces = 'false';
548
549 //Set like box variable
550 $like_box = '<div class="cff-likebox';
551 if ($cff_like_box_outside) $like_box .= ' cff-outside';
552 $like_box .= ($cff_like_box_position == 'top') ? ' top' : ' bottom';
553 $like_box .= '" ' . $cff_likebox_styles . '><script src="https://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 .'" data-height="'.$cff_likebox_height.'"></fb:like-box></div>';
554 //Don't show like box if it's a group
555 if($cff_is_group) $like_box = '';
556
557
558 //Feed header
559 $cff_show_header = $atts['showheader'];
560 ($cff_show_header == 'true' || $cff_show_header == 'on') ? $cff_show_header = true : $cff_show_header = false;
561
562 $cff_header_outside = $atts['headeroutside'];
563 ($cff_header_outside == 'true' || $cff_header_outside == 'on') ? $cff_header_outside = true : $cff_header_outside = false;
564
565 $cff_header_text = $atts['headertext'];
566 $cff_header_icon = $atts['headericon'];
567 $cff_header_icon_color = $atts['headericoncolor'];
568 $cff_header_icon_size = $atts['headericonsize'];
569
570 $cff_header = '<h3 class="cff-header';
571 if ($cff_header_outside) $cff_header .= ' cff-outside';
572 $cff_header .= '"' . $cff_header_styles . '>';
573 $cff_header .= '<i class="fa fa-' . $cff_header_icon . '"';
574 if(!empty($cff_header_icon_color) || !empty($cff_header_icon_size)) $cff_header .= ' style="';
575 if(!empty($cff_header_icon_color)) $cff_header .= 'color: #' . str_replace('#', '', $cff_header_icon_color) . ';';
576 if(!empty($cff_header_icon_size)) $cff_header .= ' font-size: ' . $cff_header_icon_size . 'px;';
577 if(!empty($cff_header_icon_color) || !empty($cff_header_icon_size))$cff_header .= '"';
578 $cff_header .= '></i>';
579 $cff_header .= '<span class="header-text" style="height: '.$cff_header_icon_size.'px;">' . $cff_header_text . '</span>';
580 $cff_header .= '</h3>';
581
582
583 //***START FEED***
584 $cff_content = '';
585
586 //Add the page header to the outside of the top of feed
587 if ($cff_show_header && $cff_header_outside) $cff_content .= $cff_header;
588
589 //Add like box to the outside of the top of feed
590 if ($cff_like_box_position == 'top' && $cff_show_like_box && $cff_like_box_outside) $cff_content .= $like_box;
591
592 //Create CFF container HTML
593 $cff_content .= '<div class="cff-wrapper">';
594 $cff_content .= '<div id="cff" rel="'.$title_limit.'" class="';
595 if( !empty($cff_class) ) $cff_content .= $cff_class . ' ';
596 if ( !empty($cff_feed_height) ) $cff_content .= 'cff-fixed-height ';
597 $cff_content .= '" ' . $cff_feed_styles . '>';
598
599 //Add the page header to the inside of the top of feed
600 if ($cff_show_header && !$cff_header_outside) $cff_content .= $cff_header;
601
602 //Add like box to the inside of the top of feed
603 if ($cff_like_box_position == 'top' && $cff_show_like_box && !$cff_like_box_outside) $cff_content .= $like_box;
604 //Limit var
605 $i = 0;
606
607 //Define array for post items
608 $cff_posts_array = array();
609
610 //ALL POSTS
611 if (!$cff_events_only){
612
613 $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;
614
615 //Don't use caching if the cache time is set to zero
616 if ($cff_cache_time != 0){
617 // Get any existing copy of our transient data
618 $transient_name = 'cff_'. $graph_query .'_json_' . $page_id;
619 if ( false === ( $posts_json = get_transient( $transient_name ) ) || $posts_json === null ) {
620 //Get the contents of the Facebook page
621 $posts_json = cff_fetchUrl($cff_posts_json_url);
622 //Cache the JSON
623 set_transient( $transient_name, $posts_json, $cache_seconds );
624 } else {
625 $posts_json = get_transient( $transient_name );
626 //If we can't find the transient then fall back to just getting the json from the api
627 if ($posts_json == false) $posts_json = cff_fetchUrl($cff_posts_json_url);
628 }
629 } else {
630 $posts_json = cff_fetchUrl($cff_posts_json_url);
631 }
632
633
634
635 //Interpret data with JSON
636 $FBdata = json_decode($posts_json);
637 //***STARTS POSTS LOOP***
638 foreach ($FBdata->data as $news )
639 {
640 //Explode News and Page ID's into 2 values
641 $PostID = explode("_", $news->id);
642 //Check the post type
643 $cff_post_type = $news->type;
644 if ($cff_post_type == 'link') {
645 isset($news->story) ? $story = $news->story : $story = '';
646 //Check whether it's an event
647 $event_link_check = "facebook.com/events/";
648 $event_link_check = stripos($news->link, $event_link_check);
649 if ( $event_link_check ) $cff_post_type = 'event';
650 }
651 //Should we show this post or not?
652 $cff_show_post = false;
653 switch ($cff_post_type) {
654 case 'link':
655 if ( $cff_show_links_type ) $cff_show_post = true;
656 break;
657 case 'event':
658 if ( $cff_show_event_type ) $cff_show_post = true;
659 break;
660 case 'video':
661 if ( $cff_show_video_type ) $cff_show_post = true;
662 break;
663 case 'swf':
664 if ( $cff_show_video_type ) $cff_show_post = true;
665 break;
666 case 'photo':
667 if ( $cff_show_photos_type ) $cff_show_post = true;
668 break;
669 case 'offer':
670 $cff_show_post = true;
671 break;
672 case 'status':
673 //Check whether it's a status (author comment or like)
674 if ( $cff_show_status_type && !empty($news->message) ) $cff_show_post = true;
675 break;
676 }
677
678
679 //ONLY show posts by others
680 if ( $cff_show_only_others ) {
681 //Get the numeric ID of the page
682 $page_object = cff_fetchUrl('https://graph.facebook.com/' . $page_id);
683 $page_object = json_decode($page_object);
684 $numeric_page_id = $page_object->id;
685
686 //If the post author's ID is the same as the page ID then don't show the post
687 if ( $numeric_page_id == $news->from->id ) $cff_show_post = false;
688 }
689
690
691 //Is it a duplicate post?
692 if (!isset($prev_post_message)) $prev_post_message = '';
693 if (!isset($prev_post_link)) $prev_post_link = '';
694 if (!isset($prev_post_description)) $prev_post_description = '';
695 isset($news->message) ? $pm = $news->message : $pm = '';
696 isset($news->link) ? $pl = $news->link : $pl = '';
697 isset($news->description) ? $pd = $news->description : $pd = '';
698
699 if ( ($prev_post_message == $pm) && ($prev_post_link == $pl) && ($prev_post_description == $pd) ) $cff_show_post = false;
700
701 //Check post type and display post if selected
702 if ( $cff_show_post ) {
703 //If it isn't then create the post
704 //Only create posts for the amount of posts specified
705 if ( $i == $show_posts ) break;
706 $i++;
707 //********************************//
708 //***COMPILE SECTION VARIABLES***//
709 //********************************//
710 //Set the post link
711 isset($news->link) ? $link = htmlspecialchars($news->link) : $link = '';
712 //Is it a shared album?
713 $shared_album_string = 'shared an album:';
714 isset($news->story) ? $story = $news->story : $story = '';
715 $shared_album = stripos($story, $shared_album_string);
716 if ( $shared_album ) {
717 $link = str_replace('photo.php?','media/set/?',$link);
718 }
719
720 //Is it an album?
721 $cff_album = false;
722 $album_string = 'relevant_count=';
723 $relevant_count = stripos($link, $album_string);
724
725 if ( $relevant_count ) {
726 //If relevant_count is larger than 1 then there are multiple photos
727 $relevant_count = explode('relevant_count=', $link);
728 $num_photos = intval($relevant_count[1]);
729 if ( $num_photos > 1 ) {
730 $cff_album = true;
731
732 //Link to the album instead of the photo
733 $album_link = str_replace('photo.php?','media/set/?',$link);
734 $link = "https://www.facebook.com/" . $page_id . "/posts/" . $PostID[1];
735 }
736 }
737
738 //If there's no link provided then link to either the Facebook page or the individual status
739 if (empty($news->link)) {
740 if ($cff_link_to_timeline == true){
741 //Link to page
742 $link = 'http://facebook.com/' . $page_id;
743 } else {
744 //Link to status
745 $link = "https://www.facebook.com/" . $page_id . "/posts/" . $PostID[1];
746 }
747 }
748
749 //POST AUTHOR
750 $cff_author = '<div class="cff-author"><a href="https://facebook.com/' . $news->from->id . '" '.$target.' title="'.$news->from->name.' on Facebook" '.$cff_author_styles.'>';
751
752 //Set the author image as a variable. If it already exists then don't query the api for it again.
753 $cff_author_img_var = '$cff_author_img_' . $news->from->id;
754 if ( !isset($$cff_author_img_var) ) $$cff_author_img_var = 'https://graph.facebook.com/' . $news->from->id . '/picture?type=square';
755 $cff_author .= '<img src="'.$$cff_author_img_var.'" title="'.$news->from->name.'" alt="'.$news->from->name.'" width=50 height=50>';
756 $cff_author .= '<span class="cff-page-name">'.$news->from->name.'</span>';
757 $cff_author .= '</a></div>';
758
759 //POST TEXT
760 $cff_translate_photos_text = $atts['photostext'];
761 if (!isset($cff_translate_photos_text) || empty($cff_translate_photos_text)) $cff_translate_photos_text = 'photos';
762 $cff_post_text = '<' . $cff_title_format . ' class="cff-post-text" ' . $cff_title_styles . '>';
763 $cff_post_text .= '<span class="cff-text">';
764 if ($cff_title_link) $cff_post_text .= '<a class="cff-post-text-link" href="'.$link.'" '.$target.'>';
765 //Which content should we use?
766 $cff_post_text_type = '';
767 //Use the story
768 if (!empty($news->story)) {
769 $post_text = htmlspecialchars($news->story);
770 $cff_post_text_type = 'story';
771 }
772 //Use the message
773 if (!empty($news->message)) {
774 $post_text = htmlspecialchars($news->message);
775 $cff_post_text_type = 'message';
776 }
777 //Use the name
778 if (!empty($news->name) && empty($news->story) && empty($news->message)) {
779 $post_text = htmlspecialchars($news->name);
780 $cff_post_text_type = 'name';
781 }
782 if ($cff_album) {
783 if (!empty($news->name)) {
784 $post_text = htmlspecialchars($news->name);
785 $cff_post_text_type = 'name';
786 }
787 if (!empty($news->message) && empty($news->name)) {
788 $post_text = htmlspecialchars($news->message);
789 $cff_post_text_type = 'message';
790 }
791 $post_text .= ' (' . $num_photos . ' '.$cff_translate_photos_text.')';
792 }
793
794
795 //MESSAGE TAGS
796 $cff_post_tags = $atts[ 'posttags' ];
797 //If the post tags option doesn't exist yet (ie. on plugin update) then set them as true
798 if ( !array_key_exists( 'cff_post_tags', $options ) ) $cff_post_tags = true;
799 //Add message and story tags if there are any and the post text is the message or the story
800 if( $cff_post_tags && ( isset($news->message_tags) || isset($news->story_tags) ) && ($cff_post_text_type == 'message' || $cff_post_text_type == 'story') && !$cff_title_link){
801 //Use message_tags or story_tags?
802 ( isset($news->message_tags) )? $text_tags = $news->message_tags : $text_tags = $news->story_tags;
803
804 //If message tags and message is being used as the post text, or same with story. This stops story tags being used to replace the message inadvertently.
805 if( ( $cff_post_text_type == 'message' && isset($news->message_tags) ) || ( $cff_post_text_type == 'story' && !isset($news->message_tags) ) ) {
806
807 //Does the Post Text contain any html tags? - the & symbol is the best indicator of this
808 $cff_html_check_array = array('&lt;', '', '', '&quot;', '&amp;');
809
810 //always use the text replace method
811 if( stripos_arr($post_text, $cff_html_check_array) !== false ) {
812 //Loop through the tags
813 foreach($text_tags as $message_tag ) {
814 $tag_name = $message_tag[0]->name;
815 $tag_link = '<a href="http://facebook.com/' . $message_tag[0]->id . '" style="color: #'.str_replace('#', '', $atts['textlinkcolor']).';" target="_blank">' . $message_tag[0]->name . '</a>';
816
817 $post_text = str_replace($tag_name, $tag_link, $post_text);
818 }
819
820 } else {
821 //If it doesn't contain HTMl tags then use the offset to replace message tags
822 $message_tags_arr = array();
823
824 $i = 0;
825 foreach($text_tags as $message_tag ) {
826 $i++;
827 $message_tags_arr = array_push_assoc(
828 $message_tags_arr,
829 $i,
830 array(
831 'id' => $message_tag[0]->id,
832 'name' => $message_tag[0]->name,
833 'type' => $message_tag[0]->type,
834 'offset' => $message_tag[0]->offset,
835 'length' => $message_tag[0]->length
836 )
837 );
838 }
839
840 for($i = count($message_tags_arr); $i >= 1; $i--) {
841
842 $b = '<a href="http://facebook.com/' . $message_tags_arr[$i]['id'] . '" style="color: #'.str_replace('#', '', $atts['textlinkcolor']).';" target="_blank">' . $message_tags_arr[$i]['name'] . '</a>';
843 $c = $message_tags_arr[$i]['offset'];
844 $d = $message_tags_arr[$i]['length'];
845
846 $post_text = mb_substr_replace( $post_text, $b, $c, $d);
847
848 }
849
850 } // end if/else
851
852 } // end message check
853
854 } //END MESSAGE TAGS
855
856 //Replace line breaks in text (needed for IE8)
857 $post_text = preg_replace("/\r\n|\r|\n/",'<br/>', $post_text);
858
859 //If the text is wrapped in a link then don't hyperlink any text within
860 if ($cff_title_link) {
861 //Wrap links in a span so we can break the text if it's too long
862 $cff_post_text .= cff_wrap_span( $post_text ) . ' ';
863 } else {
864 //Don't use htmlspecialchars for post_text as it's added above so that it doesn't mess up the message_tag offsets
865 $cff_post_text .= cff_autolink( $post_text, $link_color=str_replace('#', '', $atts['textlinkcolor']) ) . ' ';
866 }
867
868 if ($cff_title_link) $cff_post_text .= '</a>';
869 $cff_post_text .= '</span>';
870 //'See More' link
871 $cff_post_text .= '<span class="cff-expand">... <a href="#" style="color: #'.str_replace('#', '', $atts['textlinkcolor']).'"><span class="cff-more">' . $cff_see_more_text . '</span><span class="cff-less">' . $cff_see_less_text . '</span></a></span>';
872 $cff_post_text .= '</' . $cff_title_format . '>';
873
874 //DESCRIPTION
875 $cff_description = '';
876 //Use the description if it's available and the post type isn't set to offer (offer description isn't useful)
877 if ( ( !empty($news->description) || !empty($news->caption) ) && $cff_post_type != 'offer') {
878
879 $description_text = '';
880 if ( !empty($news->description) ) {
881 $description_text = $news->description;
882 } else {
883 $description_text = $news->caption;
884 }
885
886 if (!empty($body_limit)) {
887 if (strlen($description_text) > $body_limit) $description_text = substr($description_text, 0, $body_limit) . '...';
888 }
889 $cff_description .= '<p class="cff-post-desc" '.$cff_body_styles.'><span>' . cff_autolink( htmlspecialchars($description_text) ) . '</span></p>';
890
891 //If the post text and description/caption are the same then don't show the description
892 if($post_text == $description_text) $cff_description = '';
893
894 }
895
896 //LINK
897 $cff_shared_link = '';
898 //Display shared link
899 if ($cff_post_type == 'link') {
900 $cff_shared_link .= '<div class="cff-shared-link';
901 if($cff_disable_link_box) $cff_shared_link .= ' cff-no-styles"';
902 if(!$cff_disable_link_box) $cff_shared_link .= '" ' . $cff_link_box_styles;
903 $cff_shared_link .= '>';
904
905 //Display link name and description
906 if (!empty($news->description)) {
907 $cff_shared_link .= '<div class="cff-text-link ';
908 $cff_shared_link .= 'cff-no-image';
909 //The link title:
910 $cff_shared_link .= '"><'.$cff_link_title_format.' class="cff-link-title" '.$cff_link_title_styles.'><a href="'.$link.'" '.$target.' style="color:#' . str_replace('#', '', $cff_link_title_color) . ';">'. $news->name . '</a></'.$cff_link_title_format.'>';
911 //The link source:
912 if(!empty($news->caption)) $cff_shared_link .= '<p class="cff-link-caption" style="color:#' . str_replace('#', '', $cff_link_url_color) . ';">'.$news->caption.'</p>';
913 if ($cff_show_desc) {
914 $cff_shared_link .= $cff_description;
915 }
916 $cff_shared_link .= '</div>';
917 }
918
919 $cff_shared_link .= '</div>';
920 }
921
922 //DATE
923 $cff_date_formatting = $atts[ 'dateformat' ];
924 $cff_date_custom = $atts[ 'datecustom' ];
925
926 $post_time = $news->created_time;
927 $cff_date = '<p class="cff-date" '.$cff_date_styles.'>'. $cff_date_before . ' ' . cff_getdate(strtotime($post_time), $cff_date_formatting, $cff_date_custom) . ' ' . $cff_date_after . '</p>';
928 //EVENT
929 $cff_event = '';
930 if ($cff_show_event_title || $cff_show_event_details) {
931 //Check for media
932 if ($cff_post_type == 'event') {
933
934 //Get the event id from the event URL. eg: http://www.facebook.com/events/123451234512345/
935 $event_url = parse_url($link);
936 $url_parts = explode('/', $event_url['path']);
937 //Get the id from the parts
938 $eventID = $url_parts[count($url_parts)-2];
939
940 //Get the contents of the event using the WP HTTP API
941 $event_json_url = 'https://graph.facebook.com/'.$eventID.'?access_token=' . $access_token . $cff_ssl;
942
943 //Don't use caching if the cache time is set to zero
944 if ($cff_cache_time != 0){
945 // Get any existing copy of our transient data
946 $transient_name = 'cff_timeline_event_json_' . $eventID;
947 if ( false === ( $event_json = get_transient( $transient_name ) ) || $event_json === null ) {
948 //Get the contents of the Facebook page
949 $event_json = cff_fetchUrl($event_json_url);
950 //Cache the JSON
951 set_transient( $transient_name, $event_json, $cache_seconds );
952 } else {
953 $event_json = get_transient( $transient_name );
954 //If we can't find the transient then fall back to just getting the json from the api
955 if ($event_json == false) $event_json = cff_fetchUrl($event_json_url);
956 }
957 } else {
958 $event_json = cff_fetchUrl($event_json_url);
959 }
960
961 //Interpret data with JSON
962 $event_object = json_decode($event_json);
963 //Event date
964 isset( $event_object->start_time ) ? $event_time = $event_object->start_time : $event_time = '';
965 //If timezone migration is enabled then remove last 5 characters
966 if ( strlen($event_time) == 24 ) $event_time = substr($event_time, 0, -5);
967 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>';
968 //EVENT
969 //Display the event details
970 $cff_event .= '<div class="cff-details">';
971 //show event date above title
972 if ($cff_event_date_position == 'above') $cff_event .= $cff_event_date;
973 //Show event title
974 if ($cff_show_event_title && !empty($event_object->name)) {
975 if ($cff_event_title_link) $cff_event .= '<a href="'.$link.'">';
976 $cff_event .= '<' . $cff_event_title_format . ' ' . $cff_event_title_styles . '>' . $event_object->name . '</' . $cff_event_title_format . '>';
977 if ($cff_event_title_link) $cff_event .= '</a>';
978 }
979 //show event date below title
980 if ($cff_event_date_position !== 'above') $cff_event .= $cff_event_date;
981 //Show event details
982 if ($cff_show_event_details){
983 //Location
984 if (!empty($event_object->location)) $cff_event .= '<p class="cff-where" ' . $cff_event_details_styles . '>' . $event_object->location . '</p>';
985 //Description
986 if (!empty($event_object->description)){
987 $description = $event_object->description;
988 if (!empty($body_limit)) {
989 if (strlen($description) > $body_limit) $description = substr($description, 0, $body_limit) . '...';
990 }
991 $cff_event .= '<p class="cff-info" ' . $cff_event_details_styles . '>' . cff_autolink($description, $link_color=str_replace('#', '', $cff_event_link_color) ) . '</p>';
992 }
993 }
994 $cff_event .= '</div>';
995
996 }
997 }
998
999 /* VIDEO */
1000 $cff_is_video_embed = false;
1001 $cff_media = '';
1002 if ($news->type == 'video') {
1003 $cff_is_video_embed = true;
1004 //Add the name to the description if it's a video embed
1005 if($cff_is_video_embed) {
1006 isset($news->name) ? $video_name = $news->name : $video_name = $link;
1007 isset($news->description) ? $description_text = $news->description : $description_text = '';
1008 $cff_description = '<div class="cff-desc-wrap cff-shared-link ';
1009 if (empty($picture)) $cff_description .= 'cff-no-image';
1010 if($cff_disable_link_box) $cff_description .= ' cff-no-styles"';
1011 if(!$cff_disable_link_box) $cff_description .= '" ' . $cff_link_box_styles;
1012 $cff_description .= '>';
1013
1014 if( isset($news->name) ) $cff_description .= '<'.$cff_link_title_format.' class="cff-link-title" '.$cff_link_title_styles.'><a href="'.$link.'" '.$target.' style="color:#' . str_replace('#', '', $cff_link_title_color) . ';">'. $news->name . '</a></'.$cff_link_title_format.'>';
1015
1016 if (!empty($body_limit)) {
1017 if (strlen($description_text) > $body_limit) $description_text = substr($description_text, 0, $body_limit) . '...';
1018 }
1019
1020 $cff_description .= '<p class="cff-post-desc" '.$cff_body_styles.'><span>' . cff_autolink( htmlspecialchars($description_text) ) . '</span></p></div>';
1021 }
1022 }
1023
1024
1025 //Display the link to the Facebook post or external link
1026 $cff_link = '';
1027 //Default link
1028 $cff_viewpost_class = 'cff-viewpost-facebook';
1029 if ($cff_facebook_link_text == '') $cff_facebook_link_text = 'View on Facebook';
1030 $link_text = $cff_facebook_link_text;
1031
1032 //Link to the Facebook post if it's a link or a video
1033 if($cff_post_type == 'link' || $cff_post_type == 'video') $link = "https://www.facebook.com/" . $page_id . "/posts/" . $PostID[1];
1034
1035 if ($cff_post_type == 'offer') $link_text = 'View Offer';
1036 $cff_link = '<a class="' . $cff_viewpost_class . '" href="' . $link . '" title="' . $link_text . '" ' . $target . ' ' . $cff_link_styles . '>' . $link_text . '</a>';
1037
1038
1039 //**************************//
1040 //***CREATE THE POST HTML***//
1041 //**************************//
1042 //Start the container
1043 $cff_post_item = '<div class="cff-item ';
1044 if ($cff_post_type == 'link') $cff_post_item .= 'cff-link-item';
1045 if ($cff_post_type == 'event') $cff_post_item .= 'cff-timeline-event';
1046 if ($cff_post_type == 'photo') $cff_post_item .= 'cff-photo-post';
1047 if ($cff_post_type == 'video') $cff_post_item .= 'cff-video-post';
1048 if ($cff_post_type == 'swf') $cff_post_item .= 'cff-swf-post';
1049 if ($cff_post_type == 'status') $cff_post_item .= 'cff-status-post';
1050 if ($cff_post_type == 'offer') $cff_post_item .= 'cff-offer-post';
1051 if ($cff_album) $cff_post_item .= ' cff-album';
1052 $cff_post_item .= ' author-'. to_slug($news->from->name) .'" id="'. $news->id .'" ' . $cff_item_styles . '>';
1053
1054 //POST AUTHOR
1055 if($cff_show_author) $cff_post_item .= $cff_author;
1056 //DATE ABOVE
1057 if ($cff_show_date && $cff_date_position == 'above') $cff_post_item .= $cff_date;
1058 //POST TEXT
1059 if($cff_show_text) $cff_post_item .= $cff_post_text;
1060 //DESCRIPTION
1061 if($cff_show_desc && $cff_post_type != 'offer' && $cff_post_type != 'link') $cff_post_item .= $cff_description;
1062 //LINK
1063 if($cff_show_shared_links) $cff_post_item .= $cff_shared_link;
1064 //DATE BELOW
1065 if ($cff_show_date && $cff_date_position == 'below') $cff_post_item .= $cff_date;
1066 //EVENT
1067 if($cff_show_event_title || $cff_show_event_details) $cff_post_item .= $cff_event;
1068 //VIEW ON FACEBOOK LINK
1069 if($cff_show_link) $cff_post_item .= $cff_link;
1070
1071 //End the post item
1072 $cff_post_item .= '</div>';
1073
1074 //PUSH TO ARRAY
1075 $cff_posts_array = array_push_assoc($cff_posts_array, strtotime($post_time), $cff_post_item);
1076
1077 } // End post type check
1078
1079 if (isset($news->message)) $prev_post_message = $news->message;
1080 if (isset($news->link)) $prev_post_link = $news->link;
1081 if (isset($news->description)) $prev_post_description = $news->description;
1082
1083 } // End the loop
1084
1085 //Sort the array in reverse order (newest first)
1086 krsort($cff_posts_array);
1087
1088 } // End ALL POSTS
1089
1090
1091 //Output the posts array
1092 $p = 0;
1093 foreach ($cff_posts_array as $post ) {
1094 if ( $p == $show_posts ) break;
1095 $cff_content .= $post;
1096 $p++;
1097 }
1098
1099 //Reset the timezone
1100 date_default_timezone_set( $cff_orig_timezone );
1101 //Add the Like Box inside
1102 if ($cff_like_box_position == 'bottom' && $cff_show_like_box && !$cff_like_box_outside) $cff_content .= $like_box;
1103 //End the feed
1104 $cff_content .= '</div><div class="cff-clear"></div>';
1105 //Add the Like Box outside
1106 if ($cff_like_box_position == 'bottom' && $cff_show_like_box && $cff_like_box_outside) $cff_content .= $like_box;
1107
1108 //If the feed is loaded via Ajax then put the scripts into the shortcode itself
1109 $ajax_theme = $atts['ajax'];
1110 ( $ajax_theme == 'on' || $ajax_theme == 'true' || $ajax_theme == true ) ? $ajax_theme = true : $ajax_theme = false;
1111 if( $atts[ 'ajax' ] == 'false' ) $ajax_theme = false;
1112 if ($ajax_theme) $cff_content .= '<script type="text/javascript" src="' . plugins_url( '/js/cff-scripts.js?8' , __FILE__ ) . '"></script>';
1113
1114 $cff_content .= '</div>';
1115
1116 //Return our feed HTML to display
1117 return $cff_content;
1118 }
1119
1120 //***FUNCTIONS***
1121
1122 //Get JSON object of feed data
1123 function cff_fetchUrl($url){
1124 //Can we use cURL?
1125 if(is_callable('curl_init')){
1126 $ch = curl_init();
1127 curl_setopt($ch, CURLOPT_URL, $url);
1128 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1129 curl_setopt($ch, CURLOPT_TIMEOUT, 20);
1130 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1131 $feedData = curl_exec($ch);
1132 curl_close($ch);
1133 //If not then use file_get_contents
1134 } elseif ( ini_get('allow_url_fopen') == 1 || ini_get('allow_url_fopen') === TRUE ) {
1135 $feedData = @file_get_contents($url);
1136 //Or else use the WP HTTP API
1137 } else {
1138 if( !class_exists( 'WP_Http' ) ) include_once( ABSPATH . WPINC. '/class-http.php' );
1139 $request = new WP_Http;
1140 $result = $request->request($url);
1141 $feedData = $result['body'];
1142 }
1143
1144 return $feedData;
1145 }
1146
1147 //Make links into span instead when the post text is made clickable
1148 function cff_wrap_span($text) {
1149 $pattern = '#\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))#';
1150 return preg_replace_callback($pattern, 'cff_wrap_span_callback', $text);
1151 }
1152 function cff_wrap_span_callback($matches) {
1153 $max_url_length = 100;
1154 $max_depth_if_over_length = 2;
1155 $ellipsis = '&hellip;';
1156 $target = 'target="_blank"';
1157 $url_full = $matches[0];
1158 $url_short = '';
1159 if (strlen($url_full) > $max_url_length) {
1160 $parts = parse_url($url_full);
1161 $url_short = $parts['scheme'] . '://' . preg_replace('/^www\./', '', $parts['host']) . '/';
1162 $path_components = explode('/', trim($parts['path'], '/'));
1163 foreach ($path_components as $dir) {
1164 $url_string_components[] = $dir . '/';
1165 }
1166 if (!empty($parts['query'])) {
1167 $url_string_components[] = '?' . $parts['query'];
1168 }
1169 if (!empty($parts['fragment'])) {
1170 $url_string_components[] = '#' . $parts['fragment'];
1171 }
1172 for ($k = 0; $k < count($url_string_components); $k++) {
1173 $curr_component = $url_string_components[$k];
1174 if ($k >= $max_depth_if_over_length || strlen($url_short) + strlen($curr_component) > $max_url_length) {
1175 if ($k == 0 && strlen($url_short) < $max_url_length) {
1176 // Always show a portion of first directory
1177 $url_short .= substr($curr_component, 0, $max_url_length - strlen($url_short));
1178 }
1179 $url_short .= $ellipsis;
1180 break;
1181 }
1182 $url_short .= $curr_component;
1183 }
1184 } else {
1185 $url_short = $url_full;
1186 }
1187 return "<span class='cff-break-word'>$url_short</span>";
1188 }
1189
1190 //2013-04-28T21:06:56+0000
1191 //Time stamp function - used for posts
1192 function cff_getdate($original, $date_format, $custom_date) {
1193 switch ($date_format) {
1194
1195 case '2':
1196 $print = date_i18n('F jS, g:i a', $original);
1197 break;
1198 case '3':
1199 $print = date_i18n('F jS', $original);
1200 break;
1201 case '4':
1202 $print = date_i18n('D F jS', $original);
1203 break;
1204 case '5':
1205 $print = date_i18n('l F jS', $original);
1206 break;
1207 case '6':
1208 $print = date_i18n('D M jS, Y', $original);
1209 break;
1210 case '7':
1211 $print = date_i18n('l F jS, Y', $original);
1212 break;
1213 case '8':
1214 $print = date_i18n('l F jS, Y - g:i a', $original);
1215 break;
1216 case '9':
1217 $print = date_i18n("l M jS, 'y", $original);
1218 break;
1219 case '10':
1220 $print = date_i18n('m.d.y', $original);
1221 break;
1222 case '11':
1223 $print = date_i18n('m/d/y', $original);
1224 break;
1225 case '12':
1226 $print = date_i18n('d.m.y', $original);
1227 break;
1228 case '13':
1229 $print = date_i18n('d/m/y', $original);
1230 break;
1231 default:
1232
1233 $options = get_option('cff_style_settings');
1234
1235 $cff_second = isset($options['cff_translate_second']) ? $options['cff_translate_second'] : '';
1236 if ( empty($cff_second) ) $cff_second = 'second';
1237
1238 $cff_seconds = isset($options['cff_translate_seconds']) ? $options['cff_translate_seconds'] : '';
1239 if ( empty($cff_seconds) ) $cff_seconds = 'seconds';
1240
1241 $cff_minute = isset($options['cff_translate_minute']) ? $options['cff_translate_minute'] : '';
1242 if ( empty($cff_minute) ) $cff_minute = 'minute';
1243
1244 $cff_minutes = isset($options['cff_translate_minutes']) ? $options['cff_translate_minutes'] : '';
1245 if ( empty($cff_minutes) ) $cff_minutes = 'minutes';
1246
1247 $cff_hour = isset($options['cff_translate_hour']) ? $options['cff_translate_hour'] : '';
1248 if ( empty($cff_hour) ) $cff_hour = 'hour';
1249
1250 $cff_hours = isset($options['cff_translate_hours']) ? $options['cff_translate_hours'] : '';
1251 if ( empty($cff_hours) ) $cff_hours = 'hours';
1252
1253 $cff_day = isset($options['cff_translate_day']) ? $options['cff_translate_day'] : '';
1254 if ( empty($cff_day) ) $cff_day = 'day';
1255
1256 $cff_days = isset($options['cff_translate_days']) ? $options['cff_translate_days'] : '';
1257 if ( empty($cff_days) ) $cff_days = 'days';
1258
1259 $cff_week = isset($options['cff_translate_week']) ? $options['cff_translate_week'] : '';
1260 if ( empty($cff_week) ) $cff_week = 'week';
1261
1262 $cff_weeks = isset($options['cff_translate_weeks']) ? $options['cff_translate_weeks'] : '';
1263 if ( empty($cff_weeks) ) $cff_weeks = 'weeks';
1264
1265 $cff_month = isset($options['cff_translate_month']) ? $options['cff_translate_month'] : '';
1266 if ( empty($cff_month) ) $cff_month = 'month';
1267
1268 $cff_months = isset($options['cff_translate_months']) ? $options['cff_translate_months'] : '';
1269 if ( empty($cff_months) ) $cff_months = 'months';
1270
1271 $cff_year = isset($options['cff_translate_year']) ? $options['cff_translate_year'] : '';
1272 if ( empty($cff_year) ) $cff_year = 'year';
1273
1274 $cff_years = isset($options['cff_translate_years']) ? $options['cff_translate_years'] : '';
1275 if ( empty($cff_years) ) $cff_years = 'years';
1276
1277 $cff_ago = isset($options['cff_translate_ago']) ? $options['cff_translate_ago'] : '';
1278 if ( empty($cff_ago) ) $cff_ago = 'ago';
1279
1280
1281 $periods = array($cff_second, $cff_minute, $cff_hour, $cff_day, $cff_week, $cff_month, $cff_year, "decade");
1282 $periods_plural = array($cff_seconds, $cff_minutes, $cff_hours, $cff_days, $cff_weeks, $cff_months, $cff_years, "decade");
1283
1284 $lengths = array("60","60","24","7","4.35","12","10");
1285 $now = time();
1286
1287 // is it future date or past date
1288 if($now > $original) {
1289 $difference = $now - $original;
1290 $tense = $cff_ago;
1291 } else {
1292 $difference = $original - $now;
1293 $tense = $cff_ago;
1294 }
1295 for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
1296 $difference /= $lengths[$j];
1297 }
1298
1299 $difference = round($difference);
1300
1301 if($difference != 1) {
1302 $periods[$j] = $periods_plural[$j];
1303 }
1304 $print = "$difference $periods[$j] {$tense}";
1305
1306 break;
1307
1308 }
1309 if ( !empty($custom_date) ){
1310 $print = date_i18n($custom_date, $original);
1311 }
1312
1313 return $print;
1314 }
1315 function cff_eventdate($original, $date_format, $custom_date) {
1316 switch ($date_format) {
1317
1318 case '2':
1319 $print = date_i18n('F jS, g:ia', $original);
1320 break;
1321 case '3':
1322 $print = date_i18n('g:ia - F jS', $original);
1323 break;
1324 case '4':
1325 $print = date_i18n('g:ia, F jS', $original);
1326 break;
1327 case '5':
1328 $print = date_i18n('l F jS - g:ia', $original);
1329 break;
1330 case '6':
1331 $print = date_i18n('D M jS, Y, g:iA', $original);
1332 break;
1333 case '7':
1334 $print = date_i18n('l F jS, Y, g:iA', $original);
1335 break;
1336 case '8':
1337 $print = date_i18n('l F jS, Y - g:ia', $original);
1338 break;
1339 case '9':
1340 $print = date_i18n("l M jS, 'y", $original);
1341 break;
1342 case '10':
1343 $print = date_i18n('m.d.y - g:iA', $original);
1344 break;
1345 case '11':
1346 $print = date_i18n('m/d/y, g:ia', $original);
1347 break;
1348 case '12':
1349 $print = date_i18n('d.m.y - g:iA', $original);
1350 break;
1351 case '13':
1352 $print = date_i18n('d/m/y, g:ia', $original);
1353 break;
1354 default:
1355 $print = date_i18n('F j, Y, g:ia', $original);
1356 break;
1357 }
1358 if ( !empty($custom_date) ){
1359 $print = date_i18n($custom_date, $original);
1360 }
1361 return $print;
1362 }
1363 //Time stamp function - used for comments
1364 function cff_timesince($original) {
1365
1366 $options = get_option('cff_style_settings');
1367
1368 $cff_second = isset($options['cff_translate_second']) ? $options['cff_translate_second'] : '';
1369 if ( empty($cff_second) ) $cff_second = 'second';
1370
1371 $cff_seconds = isset($options['cff_translate_seconds']) ? $options['cff_translate_seconds'] : '';
1372 if ( empty($cff_seconds) ) $cff_seconds = 'seconds';
1373
1374 $cff_minute = isset($options['cff_translate_minute']) ? $options['cff_translate_minute'] : '';
1375 if ( empty($cff_minute) ) $cff_minute = 'minute';
1376
1377 $cff_minutes = isset($options['cff_translate_minutes']) ? $options['cff_translate_minutes'] : '';
1378 if ( empty($cff_minutes) ) $cff_minutes = 'minutes';
1379
1380 $cff_hour = isset($options['cff_translate_hour']) ? $options['cff_translate_hour'] : '';
1381 if ( empty($cff_hour) ) $cff_hour = 'hour';
1382
1383 $cff_hours = isset($options['cff_translate_hours']) ? $options['cff_translate_hours'] : '';
1384 if ( empty($cff_hours) ) $cff_hours = 'hours';
1385
1386 $cff_day = isset($options['cff_translate_day']) ? $options['cff_translate_day'] : '';
1387 if ( empty($cff_day) ) $cff_day = 'day';
1388
1389 $cff_days = isset($options['cff_translate_days']) ? $options['cff_translate_days'] : '';
1390 if ( empty($cff_days) ) $cff_days = 'days';
1391
1392 $cff_week = isset($options['cff_translate_week']) ? $options['cff_translate_week'] : '';
1393 if ( empty($cff_week) ) $cff_week = 'week';
1394
1395 $cff_weeks = isset($options['cff_translate_weeks']) ? $options['cff_translate_weeks'] : '';
1396 if ( empty($cff_weeks) ) $cff_weeks = 'weeks';
1397
1398 $cff_month = isset($options['cff_translate_month']) ? $options['cff_translate_month'] : '';
1399 if ( empty($cff_month) ) $cff_month = 'month';
1400
1401 $cff_months = isset($options['cff_translate_months']) ? $options['cff_translate_months'] : '';
1402 if ( empty($cff_months) ) $cff_months = 'months';
1403
1404 $cff_year = isset($options['cff_translate_year']) ? $options['cff_translate_year'] : '';
1405 if ( empty($cff_year) ) $cff_year = 'year';
1406
1407 $cff_years = isset($options['cff_translate_years']) ? $options['cff_translate_years'] : '';
1408 if ( empty($cff_years) ) $cff_years = 'years';
1409
1410 $cff_ago = isset($options['cff_translate_ago']) ? $options['cff_translate_ago'] : '';
1411 if ( empty($cff_ago) ) $cff_ago = 'ago';
1412
1413
1414 $periods = array($cff_second, $cff_minute, $cff_hour, $cff_day, $cff_week, $cff_month, $cff_year, "decade");
1415 $periods_plural = array($cff_seconds, $cff_minutes, $cff_hours, $cff_days, $cff_weeks, $cff_months, $cff_years, "decade");
1416
1417 $lengths = array("60","60","24","7","4.35","12","10");
1418 $now = time();
1419
1420 // is it future date or past date
1421 if($now > $original) {
1422 $difference = $now - $original;
1423 $tense = $cff_ago;
1424 } else {
1425 $difference = $original - $now;
1426 $tense = $cff_ago;
1427 }
1428 for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
1429 $difference /= $lengths[$j];
1430 }
1431
1432 $difference = round($difference);
1433
1434 if($difference != 1) {
1435 $periods[$j] = $periods_plural[$j];
1436 }
1437 return "$difference $periods[$j] {$tense}";
1438
1439 }
1440 //Use custom stripos function if it's not available (only available in PHP 5+)
1441 if(!is_callable('stripos')){
1442 function stripos($haystack, $needle){
1443 return strpos($haystack, stristr( $haystack, $needle ));
1444 }
1445 }
1446 function stripos_arr($haystack, $needle) {
1447 if(!is_array($needle)) $needle = array($needle);
1448 foreach($needle as $what) {
1449 if(($pos = stripos($haystack, ltrim($what) ))!==false) return $pos;
1450 }
1451 return false;
1452 }
1453 function mb_substr_replace($string, $replacement, $start, $length=NULL) {
1454 if (is_array($string)) {
1455 $num = count($string);
1456 // $replacement
1457 $replacement = is_array($replacement) ? array_slice($replacement, 0, $num) : array_pad(array($replacement), $num, $replacement);
1458 // $start
1459 if (is_array($start)) {
1460 $start = array_slice($start, 0, $num);
1461 foreach ($start as $key => $value)
1462 $start[$key] = is_int($value) ? $value : 0;
1463 }
1464 else {
1465 $start = array_pad(array($start), $num, $start);
1466 }
1467 // $length
1468 if (!isset($length)) {
1469 $length = array_fill(0, $num, 0);
1470 }
1471 elseif (is_array($length)) {
1472 $length = array_slice($length, 0, $num);
1473 foreach ($length as $key => $value)
1474 $length[$key] = isset($value) ? (is_int($value) ? $value : $num) : 0;
1475 }
1476 else {
1477 $length = array_pad(array($length), $num, $length);
1478 }
1479 // Recursive call
1480 return array_map(__FUNCTION__, $string, $replacement, $start, $length);
1481 }
1482 preg_match_all('/./us', (string)$string, $smatches);
1483 preg_match_all('/./us', (string)$replacement, $rmatches);
1484 if ($length === NULL) $length = mb_strlen($string);
1485 array_splice($smatches[0], $start, $length, $rmatches[0]);
1486 return join($smatches[0]);
1487 }
1488
1489 //Push to assoc array
1490 function array_push_assoc($array, $key, $value){
1491 $array[$key] = $value;
1492 return $array;
1493 }
1494 //Convert string to slug
1495 function to_slug($string){
1496 return strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $string)));
1497 }
1498
1499 // remove_filter( 'the_content', 'wpautop' );
1500 // add_filter( 'the_content', 'wpautop', 99 );
1501
1502
1503 //Allows shortcodes in theme
1504 add_filter('widget_text', 'do_shortcode');
1505
1506 //Enqueue stylesheet
1507 add_action( 'wp_enqueue_scripts', 'cff_add_my_stylesheet' );
1508 function cff_add_my_stylesheet() {
1509 // Respects SSL, Style.css is relative to the current file
1510 wp_register_style( 'cff', plugins_url('css/cff-style.css?6', __FILE__) );
1511 wp_enqueue_style( 'cff' );
1512 wp_enqueue_style( 'cff-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css', array(), '4.0.3' );
1513 }
1514 //Enqueue scripts
1515 add_action( 'wp_enqueue_scripts', 'cff_scripts_method' );
1516 function cff_scripts_method() {
1517 //Register the script to make it available
1518 wp_register_script( 'cffscripts', plugins_url( '/js/cff-scripts.js?6' , __FILE__ ), array('jquery'), '1.8', true );
1519 //Enqueue it to load it onto the page
1520 wp_enqueue_script('cffscripts');
1521 }
1522
1523 function cff_activate() {
1524 $options = get_option('cff_style_settings');
1525 $options[ 'cff_show_links_type' ] = true;
1526 $options[ 'cff_show_event_type' ] = true;
1527 $options[ 'cff_show_video_type' ] = true;
1528 $options[ 'cff_show_photos_type' ] = true;
1529 $options[ 'cff_show_status_type' ] = true;
1530 $options[ 'cff_show_author' ] = true;
1531 $options[ 'cff_show_text' ] = true;
1532 $options[ 'cff_show_desc' ] = true;
1533 $options[ 'cff_show_shared_links' ] = true;
1534 $options[ 'cff_show_date' ] = true;
1535 $options[ 'cff_show_media' ] = true;
1536 $options[ 'cff_show_event_title' ] = true;
1537 $options[ 'cff_show_event_details' ] = true;
1538 $options[ 'cff_show_meta' ] = true;
1539 $options[ 'cff_show_link' ] = true;
1540 $options[ 'cff_show_like_box' ] = true;
1541 update_option( 'cff_style_settings', $options );
1542 }
1543 register_activation_hook( __FILE__, 'cff_activate' );
1544 //Uninstall
1545 function cff_uninstall()
1546 {
1547 if ( ! current_user_can( 'activate_plugins' ) )
1548 return;
1549 //Settings
1550 delete_option( 'cff_access_token' );
1551 delete_option( 'cff_page_id' );
1552 delete_option( 'cff_num_show' );
1553 delete_option( 'cff_post_limit' );
1554 delete_option( 'cff_show_others' );
1555 delete_option('cff_cache_time');
1556 delete_option('cff_cache_time_unit');
1557 delete_option( 'cff_locale' );
1558 //Style & Layout
1559 delete_option( 'cff_title_length' );
1560 delete_option( 'cff_body_length' );
1561 delete_option('cff_style_settings');
1562 }
1563 register_uninstall_hook( __FILE__, 'cff_uninstall' );
1564 add_action( 'wp_head', 'cff_custom_css' );
1565 function cff_custom_css() {
1566 $options = get_option('cff_style_settings');
1567 isset($options[ 'cff_custom_css' ]) ? $cff_custom_css = $options[ 'cff_custom_css' ] : $cff_custom_css = '';
1568
1569 if( !empty($cff_custom_css) ) echo "\r\n";
1570 if( !empty($cff_custom_css) ) echo '<!-- Custom Facebook Feed Custom CSS -->';
1571 if( !empty($cff_custom_css) ) echo "\r\n";
1572 if( !empty($cff_custom_css) ) echo '<style type="text/css">';
1573 if( !empty($cff_custom_css) ) echo "\r\n";
1574 if( !empty($cff_custom_css) ) echo stripslashes($cff_custom_css);
1575 if( !empty($cff_custom_css) ) echo "\r\n";
1576 if( !empty($cff_custom_css) ) echo '</style>';
1577 if( !empty($cff_custom_css) ) echo "\r\n";
1578 }
1579 add_action( 'wp_footer', 'cff_js' );
1580 function cff_js() {
1581 $options = get_option('cff_style_settings');
1582 $cff_custom_js = isset($options[ 'cff_custom_js' ]) ? $options[ 'cff_custom_js' ] : '';
1583
1584 if( !empty($cff_custom_js) ) echo "\r\n";
1585 if( !empty($cff_custom_js) ) echo '<!-- Custom Facebook Feed JS -->';
1586 if( !empty($cff_custom_js) ) echo "\r\n";
1587 if( !empty($cff_custom_js) ) echo '<script type="text/javascript">';
1588 if( !empty($cff_custom_js) ) echo "\r\n";
1589 if( !empty($cff_custom_js) ) echo "jQuery( document ).ready(function($) {";
1590 if( !empty($cff_custom_js) ) echo "\r\n";
1591 if( !empty($cff_custom_js) ) echo stripslashes($cff_custom_js);
1592 if( !empty($cff_custom_js) ) echo "\r\n";
1593 if( !empty($cff_custom_js) ) echo "});";
1594 if( !empty($cff_custom_js) ) echo "\r\n";
1595 if( !empty($cff_custom_js) ) echo '</script>';
1596 if( !empty($cff_custom_js) ) echo "\r\n";
1597 }
1598
1599
1600
1601 //AUTOLINK
1602 $GLOBALS['autolink_options'] = array(
1603
1604 # Should http:// be visibly stripped from the front
1605 # of URLs?
1606 'strip_protocols' => true,
1607
1608 );
1609
1610 ####################################################################
1611
1612 function cff_autolink($text, $link_color='', $span_tag = false, $limit=100, $tagfill='class="cff-break-word"', $auto_title = true){
1613
1614 $text = cff_autolink_do($text, '![a-z][a-z-]+://!i', $limit, $tagfill, $auto_title, $span_tag, $link_color);
1615 $text = cff_autolink_do($text, '!(mailto|skype):!i', $limit, $tagfill, $auto_title, $span_tag, $link_color);
1616 $text = cff_autolink_do($text, '!www\\.!i', $limit, $tagfill, $auto_title, 'http://', $span_tag, $link_color);
1617 return $text;
1618 }
1619
1620 ####################################################################
1621
1622 function cff_autolink_do($text, $sub, $limit, $tagfill, $auto_title, $span_tag, $link_color, $force_prefix=null){
1623
1624 $text_l = StrToLower($text);
1625 $cursor = 0;
1626 $loop = 1;
1627 $buffer = '';
1628
1629 while (($cursor < strlen($text)) && $loop){
1630
1631 $ok = 1;
1632 $matched = preg_match($sub, $text_l, $m, PREG_OFFSET_CAPTURE, $cursor);
1633
1634 if (!$matched){
1635
1636 $loop = 0;
1637 $ok = 0;
1638
1639 }else{
1640
1641 $pos = $m[0][1];
1642 $sub_len = strlen($m[0][0]);
1643
1644 $pre_hit = substr($text, $cursor, $pos-$cursor);
1645 $hit = substr($text, $pos, $sub_len);
1646 $pre = substr($text, 0, $pos);
1647 $post = substr($text, $pos + $sub_len);
1648
1649 $fail_text = $pre_hit.$hit;
1650 $fail_len = strlen($fail_text);
1651
1652 #
1653 # substring found - first check to see if we're inside a link tag already...
1654 #
1655
1656 $bits = preg_split("!</a>!i", $pre);
1657 $last_bit = array_pop($bits);
1658 if (preg_match("!<a\s!i", $last_bit)){
1659
1660 #echo "fail 1 at $cursor<br />\n";
1661
1662 $ok = 0;
1663 $cursor += $fail_len;
1664 $buffer .= $fail_text;
1665 }
1666 }
1667
1668 #
1669 # looks like a nice spot to autolink from - check the pre
1670 # to see if there was whitespace before this match
1671 #
1672
1673 if ($ok){
1674
1675 if ($pre){
1676 if (!preg_match('![\s\(\[\{>]$!s', $pre)){
1677
1678 #echo "fail 2 at $cursor ($pre)<br />\n";
1679
1680 $ok = 0;
1681 $cursor += $fail_len;
1682 $buffer .= $fail_text;
1683 }
1684 }
1685 }
1686
1687 #
1688 # we want to autolink here - find the extent of the url
1689 #
1690
1691 if ($ok){
1692 if (preg_match('/^([a-z0-9\-\.\/\-_%~!?=,:;&+*#@\(\)\$]+)/i', $post, $matches)){
1693
1694 $url = $hit.$matches[1];
1695
1696 $cursor += strlen($url) + strlen($pre_hit);
1697 $buffer .= $pre_hit;
1698
1699 $url = html_entity_decode($url);
1700
1701
1702 #
1703 # remove trailing punctuation from url
1704 #
1705
1706 while (preg_match('|[.,!;:?]$|', $url)){
1707 $url = substr($url, 0, strlen($url)-1);
1708 $cursor--;
1709 }
1710 foreach (array('()', '[]', '{}') as $pair){
1711 $o = substr($pair, 0, 1);
1712 $c = substr($pair, 1, 1);
1713 if (preg_match("!^(\\$c|^)[^\\$o]+\\$c$!", $url)){
1714 $url = substr($url, 0, strlen($url)-1);
1715 $cursor--;
1716 }
1717 }
1718
1719
1720 #
1721 # nice-i-fy url here
1722 #
1723
1724 $link_url = $url;
1725 $display_url = $url;
1726
1727 if ($force_prefix) $link_url = $force_prefix.$link_url;
1728
1729 if ($GLOBALS['autolink_options']['strip_protocols']){
1730 if (preg_match('!^(http|https)://!i', $display_url, $m)){
1731
1732 $display_url = substr($display_url, strlen($m[1])+3);
1733 }
1734 }
1735
1736 $display_url = cff_autolink_label($display_url, $limit);
1737
1738
1739 #
1740 # add the url
1741 #
1742
1743 if ($display_url != $link_url && !preg_match('@title=@msi',$tagfill) && $auto_title) {
1744
1745 $display_quoted = preg_quote($display_url, '!');
1746
1747 if (!preg_match("!^(http|https)://{$display_quoted}$!i", $link_url)){
1748
1749 $tagfill .= ' title="'.$link_url.'"';
1750 }
1751 }
1752
1753 $link_url_enc = HtmlSpecialChars($link_url);
1754 $display_url_enc = HtmlSpecialChars($display_url);
1755
1756 if($span_tag == true){
1757 $buffer .= "<span $tagfill>{$display_url_enc}</span>";
1758 } else {
1759 $buffer .= "<a target='_blank' style='color: #".$link_color."' href=\"{$link_url_enc}\"$tagfill>{$display_url_enc}</a>";
1760 }
1761
1762
1763 }else{
1764 #echo "fail 3 at $cursor<br />\n";
1765
1766 $ok = 0;
1767 $cursor += $fail_len;
1768 $buffer .= $fail_text;
1769 }
1770 }
1771
1772 }
1773
1774 #
1775 # add everything from the cursor to the end onto the buffer.
1776 #
1777
1778 $buffer .= substr($text, $cursor);
1779
1780 return $buffer;
1781 }
1782
1783 ####################################################################
1784
1785 function cff_autolink_label($text, $limit){
1786
1787 if (!$limit){ return $text; }
1788
1789 if (strlen($text) > $limit){
1790 return substr($text, 0, $limit-3).'...';
1791 }
1792
1793 return $text;
1794 }
1795
1796 ####################################################################
1797
1798 function cff_autolink_email($text, $tagfill=''){
1799
1800 $atom = '[^()<>@,;:\\\\".\\[\\]\\x00-\\x20\\x7f]+'; # from RFC822
1801
1802 #die($atom);
1803
1804 $text_l = StrToLower($text);
1805 $cursor = 0;
1806 $loop = 1;
1807 $buffer = '';
1808
1809 while(($cursor < strlen($text)) && $loop){
1810
1811 #
1812 # find an '@' symbol
1813 #
1814
1815 $ok = 1;
1816 $pos = strpos($text_l, '@', $cursor);
1817
1818 if ($pos === false){
1819
1820 $loop = 0;
1821 $ok = 0;
1822
1823 }else{
1824
1825 $pre = substr($text, $cursor, $pos-$cursor);
1826 $hit = substr($text, $pos, 1);
1827 $post = substr($text, $pos + 1);
1828
1829 $fail_text = $pre.$hit;
1830 $fail_len = strlen($fail_text);
1831
1832 #die("$pre::$hit::$post::$fail_text");
1833
1834 #
1835 # substring found - first check to see if we're inside a link tag already...
1836 #
1837
1838 $bits = preg_split("!</a>!i", $pre);
1839 $last_bit = array_pop($bits);
1840 if (preg_match("!<a\s!i", $last_bit)){
1841
1842 #echo "fail 1 at $cursor<br />\n";
1843
1844 $ok = 0;
1845 $cursor += $fail_len;
1846 $buffer .= $fail_text;
1847 }
1848 }
1849
1850 #
1851 # check backwards
1852 #
1853
1854 if ($ok){
1855 if (preg_match("!($atom(\.$atom)*)\$!", $pre, $matches)){
1856
1857 # move matched part of address into $hit
1858
1859 $len = strlen($matches[1]);
1860 $plen = strlen($pre);
1861
1862 $hit = substr($pre, $plen-$len).$hit;
1863 $pre = substr($pre, 0, $plen-$len);
1864
1865 }else{
1866
1867 #echo "fail 2 at $cursor ($pre)<br />\n";
1868
1869 $ok = 0;
1870 $cursor += $fail_len;
1871 $buffer .= $fail_text;
1872 }
1873 }
1874
1875 #
1876 # check forwards
1877 #
1878
1879 if ($ok){
1880 if (preg_match("!^($atom(\.$atom)*)!", $post, $matches)){
1881
1882 # move matched part of address into $hit
1883
1884 $len = strlen($matches[1]);
1885
1886 $hit .= substr($post, 0, $len);
1887 $post = substr($post, $len);
1888
1889 }else{
1890 #echo "fail 3 at $cursor ($post)<br />\n";
1891
1892 $ok = 0;
1893 $cursor += $fail_len;
1894 $buffer .= $fail_text;
1895 }
1896 }
1897
1898 #
1899 # commit
1900 #
1901
1902 if ($ok) {
1903
1904 $cursor += strlen($pre) + strlen($hit);
1905 $buffer .= $pre;
1906 $buffer .= "<a href=\"mailto:$hit\"$tagfill>$hit</a>";
1907
1908 }
1909
1910 }
1911
1912 #
1913 # add everything from the cursor to the end onto the buffer.
1914 #
1915
1916 $buffer .= substr($text, $cursor);
1917
1918 return $buffer;
1919 }
1920
1921 ####################################################################
1922
1923
1924 //Comment out the line below to view errors
1925 // error_reporting(0);
1926 ?>