Custom Facebook Feed - Version 1.8.2.1

Version Description

  • New: Now supports Facebook tags - creates links when using the @ symbol to tag other people or Facebook pages in your posts
  • Tweak: Changed the method used for link replacement in posts
  • Fix: Fixed issue with php include
Download this release

Release Info

Developer smashballoon
Plugin Icon 128x128 Custom Facebook Feed
Version 1.8.2.1
Comparing to
See all releases

Code changes from version 1.8.2 to 1.8.2.1

Files changed (3) hide show
  1. README.txt +3 -2
  2. cff_autolink.php +339 -0
  3. custom-facebook-feed.php +1 -1
README.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: smashballoon
3
  Tags: Facebook, Facebook feed, Facebook posts, Facebook wall, Facebook events, Facebook page, Facebook group, Facebook Like box, Customizable Facebook Feed, custom, customizable, seo, responsive, mobile, social
4
  Requires at least: 3.0
5
  Tested up to: 3.8.1
6
- Stable tag: 1.8.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=H5XFD33R3FHMG
@@ -273,9 +273,10 @@ Credit [iMarketing Factory](http://www.imarketingfactory.com/facebook/ "The Impo
273
 
274
  == Changelog ==
275
 
276
- = 1.8.2 =
277
  * New: Now supports Facebook tags - creates links when using the @ symbol to tag other people or Facebook pages in your posts
278
  * Tweak: Changed the method used for link replacement in posts
 
279
 
280
  = 1.8.1 =
281
  * New: Added an 'exclude' shortcode option to allow you to easily exclude specific parts of the post
3
  Tags: Facebook, Facebook feed, Facebook posts, Facebook wall, Facebook events, Facebook page, Facebook group, Facebook Like box, Customizable Facebook Feed, custom, customizable, seo, responsive, mobile, social
4
  Requires at least: 3.0
5
  Tested up to: 3.8.1
6
+ Stable tag: 1.8.2.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=H5XFD33R3FHMG
273
 
274
  == Changelog ==
275
 
276
+ = 1.8.2.1 =
277
  * New: Now supports Facebook tags - creates links when using the @ symbol to tag other people or Facebook pages in your posts
278
  * Tweak: Changed the method used for link replacement in posts
279
+ * Fix: Fixed issue with php include
280
 
281
  = 1.8.1 =
282
  * New: Added an 'exclude' shortcode option to allow you to easily exclude specific parts of the post
cff_autolink.php ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ #
3
+ # A PHP auto-linking library
4
+ #
5
+ # https://github.com/iamcal/lib_autolink
6
+ #
7
+ # By Cal Henderson <cal@iamcal.com>
8
+ # This code is licensed under the MIT license
9
+ #
10
+
11
+ ####################################################################
12
+
13
+ #
14
+ # These are global options. You can set them before calling the autolinking
15
+ # functions to change the output.
16
+ #
17
+
18
+ $GLOBALS['autolink_options'] = array(
19
+
20
+ # Should http:// be visibly stripped from the front
21
+ # of URLs?
22
+ 'strip_protocols' => true,
23
+
24
+ );
25
+
26
+ ####################################################################
27
+
28
+ function cff_autolink($text, $span_tag = false, $limit=100, $tagfill='class="cff-break-word"', $auto_title = true){
29
+
30
+ $text = cff_autolink_do($text, '![a-z][a-z-]+://!i', $limit, $tagfill, $auto_title, $span_tag);
31
+ $text = cff_autolink_do($text, '!(mailto|skype):!i', $limit, $tagfill, $auto_title, $span_tag);
32
+ $text = cff_autolink_do($text, '!www\\.!i', $limit, $tagfill, $auto_title, 'http://', $span_tag);
33
+ return $text;
34
+ }
35
+
36
+ ####################################################################
37
+
38
+ function cff_autolink_do($text, $sub, $limit, $tagfill, $auto_title, $span_tag, $force_prefix=null){
39
+
40
+ $text_l = StrToLower($text);
41
+ $cursor = 0;
42
+ $loop = 1;
43
+ $buffer = '';
44
+
45
+ while (($cursor < strlen($text)) && $loop){
46
+
47
+ $ok = 1;
48
+ $matched = preg_match($sub, $text_l, $m, PREG_OFFSET_CAPTURE, $cursor);
49
+
50
+ if (!$matched){
51
+
52
+ $loop = 0;
53
+ $ok = 0;
54
+
55
+ }else{
56
+
57
+ $pos = $m[0][1];
58
+ $sub_len = strlen($m[0][0]);
59
+
60
+ $pre_hit = substr($text, $cursor, $pos-$cursor);
61
+ $hit = substr($text, $pos, $sub_len);
62
+ $pre = substr($text, 0, $pos);
63
+ $post = substr($text, $pos + $sub_len);
64
+
65
+ $fail_text = $pre_hit.$hit;
66
+ $fail_len = strlen($fail_text);
67
+
68
+ #
69
+ # substring found - first check to see if we're inside a link tag already...
70
+ #
71
+
72
+ $bits = preg_split("!</a>!i", $pre);
73
+ $last_bit = array_pop($bits);
74
+ if (preg_match("!<a\s!i", $last_bit)){
75
+
76
+ #echo "fail 1 at $cursor<br />\n";
77
+
78
+ $ok = 0;
79
+ $cursor += $fail_len;
80
+ $buffer .= $fail_text;
81
+ }
82
+ }
83
+
84
+ #
85
+ # looks like a nice spot to autolink from - check the pre
86
+ # to see if there was whitespace before this match
87
+ #
88
+
89
+ if ($ok){
90
+
91
+ if ($pre){
92
+ if (!preg_match('![\s\(\[\{>]$!s', $pre)){
93
+
94
+ #echo "fail 2 at $cursor ($pre)<br />\n";
95
+
96
+ $ok = 0;
97
+ $cursor += $fail_len;
98
+ $buffer .= $fail_text;
99
+ }
100
+ }
101
+ }
102
+
103
+ #
104
+ # we want to autolink here - find the extent of the url
105
+ #
106
+
107
+ if ($ok){
108
+ if (preg_match('/^([a-z0-9\-\.\/\-_%~!?=,:;&+*#@\(\)\$]+)/i', $post, $matches)){
109
+
110
+ $url = $hit.$matches[1];
111
+
112
+ $cursor += strlen($url) + strlen($pre_hit);
113
+ $buffer .= $pre_hit;
114
+
115
+ $url = html_entity_decode($url);
116
+
117
+
118
+ #
119
+ # remove trailing punctuation from url
120
+ #
121
+
122
+ while (preg_match('|[.,!;:?]$|', $url)){
123
+ $url = substr($url, 0, strlen($url)-1);
124
+ $cursor--;
125
+ }
126
+ foreach (array('()', '[]', '{}') as $pair){
127
+ $o = substr($pair, 0, 1);
128
+ $c = substr($pair, 1, 1);
129
+ if (preg_match("!^(\\$c|^)[^\\$o]+\\$c$!", $url)){
130
+ $url = substr($url, 0, strlen($url)-1);
131
+ $cursor--;
132
+ }
133
+ }
134
+
135
+
136
+ #
137
+ # nice-i-fy url here
138
+ #
139
+
140
+ $link_url = $url;
141
+ $display_url = $url;
142
+
143
+ if ($force_prefix) $link_url = $force_prefix.$link_url;
144
+
145
+ if ($GLOBALS['autolink_options']['strip_protocols']){
146
+ if (preg_match('!^(http|https)://!i', $display_url, $m)){
147
+
148
+ $display_url = substr($display_url, strlen($m[1])+3);
149
+ }
150
+ }
151
+
152
+ $display_url = cff_autolink_label($display_url, $limit);
153
+
154
+
155
+ #
156
+ # add the url
157
+ #
158
+
159
+ if ($display_url != $link_url && !preg_match('@title=@msi',$tagfill) && $auto_title) {
160
+
161
+ $display_quoted = preg_quote($display_url, '!');
162
+
163
+ if (!preg_match("!^(http|https)://{$display_quoted}$!i", $link_url)){
164
+
165
+ $tagfill .= ' title="'.$link_url.'"';
166
+ }
167
+ }
168
+
169
+ $link_url_enc = HtmlSpecialChars($link_url);
170
+ $display_url_enc = HtmlSpecialChars($display_url);
171
+
172
+ if($span_tag == true){
173
+ $buffer .= "<span $tagfill>{$display_url_enc}</span>";
174
+ } else {
175
+ $buffer .= "<a target='_blank' href=\"{$link_url_enc}\"$tagfill>{$display_url_enc}</a>";
176
+ }
177
+
178
+
179
+ }else{
180
+ #echo "fail 3 at $cursor<br />\n";
181
+
182
+ $ok = 0;
183
+ $cursor += $fail_len;
184
+ $buffer .= $fail_text;
185
+ }
186
+ }
187
+
188
+ }
189
+
190
+ #
191
+ # add everything from the cursor to the end onto the buffer.
192
+ #
193
+
194
+ $buffer .= substr($text, $cursor);
195
+
196
+ return $buffer;
197
+ }
198
+
199
+ ####################################################################
200
+
201
+ function cff_autolink_label($text, $limit){
202
+
203
+ if (!$limit){ return $text; }
204
+
205
+ if (strlen($text) > $limit){
206
+ return substr($text, 0, $limit-3).'...';
207
+ }
208
+
209
+ return $text;
210
+ }
211
+
212
+ ####################################################################
213
+
214
+ function cff_autolink_email($text, $tagfill=''){
215
+
216
+ $atom = '[^()<>@,;:\\\\".\\[\\]\\x00-\\x20\\x7f]+'; # from RFC822
217
+
218
+ #die($atom);
219
+
220
+ $text_l = StrToLower($text);
221
+ $cursor = 0;
222
+ $loop = 1;
223
+ $buffer = '';
224
+
225
+ while(($cursor < strlen($text)) && $loop){
226
+
227
+ #
228
+ # find an '@' symbol
229
+ #
230
+
231
+ $ok = 1;
232
+ $pos = strpos($text_l, '@', $cursor);
233
+
234
+ if ($pos === false){
235
+
236
+ $loop = 0;
237
+ $ok = 0;
238
+
239
+ }else{
240
+
241
+ $pre = substr($text, $cursor, $pos-$cursor);
242
+ $hit = substr($text, $pos, 1);
243
+ $post = substr($text, $pos + 1);
244
+
245
+ $fail_text = $pre.$hit;
246
+ $fail_len = strlen($fail_text);
247
+
248
+ #die("$pre::$hit::$post::$fail_text");
249
+
250
+ #
251
+ # substring found - first check to see if we're inside a link tag already...
252
+ #
253
+
254
+ $bits = preg_split("!</a>!i", $pre);
255
+ $last_bit = array_pop($bits);
256
+ if (preg_match("!<a\s!i", $last_bit)){
257
+
258
+ #echo "fail 1 at $cursor<br />\n";
259
+
260
+ $ok = 0;
261
+ $cursor += $fail_len;
262
+ $buffer .= $fail_text;
263
+ }
264
+ }
265
+
266
+ #
267
+ # check backwards
268
+ #
269
+
270
+ if ($ok){
271
+ if (preg_match("!($atom(\.$atom)*)\$!", $pre, $matches)){
272
+
273
+ # move matched part of address into $hit
274
+
275
+ $len = strlen($matches[1]);
276
+ $plen = strlen($pre);
277
+
278
+ $hit = substr($pre, $plen-$len).$hit;
279
+ $pre = substr($pre, 0, $plen-$len);
280
+
281
+ }else{
282
+
283
+ #echo "fail 2 at $cursor ($pre)<br />\n";
284
+
285
+ $ok = 0;
286
+ $cursor += $fail_len;
287
+ $buffer .= $fail_text;
288
+ }
289
+ }
290
+
291
+ #
292
+ # check forwards
293
+ #
294
+
295
+ if ($ok){
296
+ if (preg_match("!^($atom(\.$atom)*)!", $post, $matches)){
297
+
298
+ # move matched part of address into $hit
299
+
300
+ $len = strlen($matches[1]);
301
+
302
+ $hit .= substr($post, 0, $len);
303
+ $post = substr($post, $len);
304
+
305
+ }else{
306
+ #echo "fail 3 at $cursor ($post)<br />\n";
307
+
308
+ $ok = 0;
309
+ $cursor += $fail_len;
310
+ $buffer .= $fail_text;
311
+ }
312
+ }
313
+
314
+ #
315
+ # commit
316
+ #
317
+
318
+ if ($ok) {
319
+
320
+ $cursor += strlen($pre) + strlen($hit);
321
+ $buffer .= $pre;
322
+ $buffer .= "<a href=\"mailto:$hit\"$tagfill>$hit</a>";
323
+
324
+ }
325
+
326
+ }
327
+
328
+ #
329
+ # add everything from the cursor to the end onto the buffer.
330
+ #
331
+
332
+ $buffer .= substr($text, $cursor);
333
+
334
+ return $buffer;
335
+ }
336
+
337
+ ####################################################################
338
+
339
+ ?>
custom-facebook-feed.php CHANGED
@@ -3,7 +3,7 @@
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.8.2
7
  Author: Smash Balloon
8
  Author URI: http://smashballoon.com/
9
  License: GPLv2 or later
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.8.2.1
7
  Author: Smash Balloon
8
  Author URI: http://smashballoon.com/
9
  License: GPLv2 or later