Custom Facebook Feed - Version 1.3.3

Version Description

  • New: Added support for events - display the event details (name, location, date/time, description) directly in the feed
  • Fix: Links within the post text are now hyperlinked
  • Tweak: Added additional methods for retrieving feed data
Download this release

Release Info

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

Code changes from version 1.3.2 to 1.3.3

README.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: smashballoon
3
  Tags: facebook, custom, customizable, feed, seo, search engine, responsive, mobile, shortcode, social, status
4
  Requires at least: 3.0
5
  Tested up to: 3.5.1
6
- Stable tag: 1.3.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -56,6 +56,10 @@ An Access Token is required by Facebook in order to access their feeds. Don't w
56
 
57
  This plugin only allows you to display text updates from your feed. To display photos and videos in your feed you need to upgrade to the PRO version of the plugin. Try out a demo of the PRO version on the [Custom Facebook Feed website](http://smashballoon.com/custom-facebook-feed/demo "Custom Facebook Feed Demo"), and find out more about the PRO version [here](http://smashballoon.com/custom-facebook-feed/wordpress-plugin/ "Custom Facebook Feed PRO").
58
 
 
 
 
 
59
  = Is the content of my feed crawlable by search engines? =
60
 
61
  It sure is. Unlike other Facebook plugins which use iframes to embed your feed into your page once it's loaded, the Custom Facebook Feed uses PHP to embed your feed content directly into your page. This adds dynamic, search engine crawlable content to your site.
@@ -70,6 +74,11 @@ It sure is. Unlike other Facebook plugins which use iframes to embed your feed i
70
 
71
  == Changelog ==
72
 
 
 
 
 
 
73
  = 1.3.2 =
74
  * Fix: Now using the built-in WordPress HTTP API to get retrieve the Facebook data
75
 
3
  Tags: facebook, custom, customizable, feed, seo, search engine, responsive, mobile, shortcode, social, status
4
  Requires at least: 3.0
5
  Tested up to: 3.5.1
6
+ Stable tag: 1.3.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
56
 
57
  This plugin only allows you to display text updates from your feed. To display photos and videos in your feed you need to upgrade to the PRO version of the plugin. Try out a demo of the PRO version on the [Custom Facebook Feed website](http://smashballoon.com/custom-facebook-feed/demo "Custom Facebook Feed Demo"), and find out more about the PRO version [here](http://smashballoon.com/custom-facebook-feed/wordpress-plugin/ "Custom Facebook Feed PRO").
58
 
59
+ = Can I show the comments associated with each post? =
60
+
61
+ For this feature please upgrade to the [PRO version of the plugin](http://smashballoon.com/custom-facebook-feed/wordpress-plugin/ "Custom Facebook Feed PRO").
62
+
63
  = Is the content of my feed crawlable by search engines? =
64
 
65
  It sure is. Unlike other Facebook plugins which use iframes to embed your feed into your page once it's loaded, the Custom Facebook Feed uses PHP to embed your feed content directly into your page. This adds dynamic, search engine crawlable content to your site.
74
 
75
  == Changelog ==
76
 
77
+ = 1.3.3 =
78
+ * New: Added support for events - display the event details (name, location, date/time, description) directly in the feed
79
+ * Fix: Links within the post text are now hyperlinked
80
+ * Tweak: Added additional methods for retrieving feed data
81
+
82
  = 1.3.2 =
83
  * Fix: Now using the built-in WordPress HTTP API to get retrieve the Facebook data
84
 
css/style.css CHANGED
@@ -30,12 +30,9 @@
30
 
31
  /* Links */
32
  #cff a {
33
- display: block;
34
- padding: 5px 0;
35
  color:#666;
36
  text-decoration:underline;
37
  }
38
-
39
  #cff a:active, #cff a:hover {
40
  color: #000;
41
  }
@@ -64,10 +61,24 @@
64
  #cff .cff-date{
65
  float: left;
66
  width: 100%;
67
- padding-top: 5px;
68
  font-size: 11px;
69
  }
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  /*****************/
73
  /*** POST META ***/
30
 
31
  /* Links */
32
  #cff a {
 
 
33
  color:#666;
34
  text-decoration:underline;
35
  }
 
36
  #cff a:active, #cff a:hover {
37
  color: #000;
38
  }
61
  #cff .cff-date{
62
  float: left;
63
  width: 100%;
 
64
  font-size: 11px;
65
  }
66
 
67
+ /* Event */
68
+ #cff .details{
69
+ float: left;
70
+ clear: both;
71
+ width: 100%;
72
+ padding: 15px 0 10px 0;
73
+ }
74
+ #cff .details h5{
75
+ margin: 0 0 5px 0;
76
+ font-size: 16px;
77
+ }
78
+ #cff .details p{
79
+ font-size: 14px;
80
+ }
81
+
82
 
83
  /*****************/
84
  /*** POST META ***/
custom-facebook-feed-admin.php CHANGED
@@ -114,7 +114,7 @@ function cff_settings_page() {
114
 
115
  <tr valign="top">
116
 
117
- <th scope="row"><?php _e('Maximum Post Title Length'); ?></th>
118
 
119
  <td>
120
 
@@ -126,7 +126,7 @@ function cff_settings_page() {
126
 
127
  <tr valign="top">
128
 
129
- <th scope="row"><?php _e('Maximum Post Body Text Length'); ?></th>
130
 
131
  <td>
132
 
@@ -159,7 +159,7 @@ function cff_settings_page() {
159
 
160
  <p>[custom-facebook-feed <b>id=Your_Page_ID show=3 titlelength=100 bodylength=150</b>]</p>
161
 
162
- <br /><br /><a href="http://smashballoon.com/custom-facebook-feed/" target="_blank">Plugin Support</a>
163
 
164
  <br /><br /><br />
165
  <a href="http://smashballoon.com/custom-facebook-feed/troubleshooting" target="_blank"><img src="<?php echo plugins_url( 'img/pro.jpg' , __FILE__ ) ?>" /></a>
114
 
115
  <tr valign="top">
116
 
117
+ <th scope="row"><?php _e('Maximum Post Text Length'); ?></th>
118
 
119
  <td>
120
 
126
 
127
  <tr valign="top">
128
 
129
+ <th scope="row"><?php _e('Maximum Link/Event Description Length'); ?></th>
130
 
131
  <td>
132
 
159
 
160
  <p>[custom-facebook-feed <b>id=Your_Page_ID show=3 titlelength=100 bodylength=150</b>]</p>
161
 
162
+ <br /><br /><a href="http://smashballoon.com/custom-facebook-feed/" target="_blank">Plugin Support</a> - Smash Balloon is committed to making this plugin better. Please let us know if you have had any issues when using this plugin so that we can continue to make it better!
163
 
164
  <br /><br /><br />
165
  <a href="http://smashballoon.com/custom-facebook-feed/troubleshooting" target="_blank"><img src="<?php echo plugins_url( 'img/pro.jpg' , __FILE__ ) ?>" /></a>
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.3.2
7
  Author: Smash Balloon
8
  Author URI: http://smashballoon.com/
9
  License: GPLv2 or later
@@ -30,8 +30,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30
  //Include admin
31
  include dirname( __FILE__ ) .'/custom-facebook-feed-admin.php';
32
 
33
- error_reporting(0);
34
-
35
  // Add shortcodes
36
  add_shortcode('custom-facebook-feed', 'display_cff');
37
  function display_cff($atts) {
@@ -64,29 +62,41 @@ function display_cff($atts) {
64
  return false;
65
  }
66
 
67
- // cURL used to get JSON object of feed data
68
- function fetchUrl($url){
69
- $ch = curl_init();
70
- curl_setopt($ch, CURLOPT_URL, $url);
71
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
72
- curl_setopt($ch, CURLOPT_TIMEOUT, 20);
73
- // Uncomment below if using SSL
74
- // curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
75
 
76
- $feedData = curl_exec($ch);
77
- curl_close($ch);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
 
 
79
  return $feedData;
80
  }
81
 
82
- //Get the contents of the Facebook feed using the WP HTTP API
83
- if( !class_exists( 'WP_Http' ) )
84
- include_once( ABSPATH . WPINC. '/class-http.php' );
85
 
86
- $feed_url = 'https://graph.facebook.com/' . $page_id . '/posts?access_token=' . $access_token;
87
- $request = new WP_Http;
88
- $result = $request->request( $feed_url );
89
- $json_object = $result['body'];
90
 
91
  //Interpret data with JSON
92
  $FBdata = json_decode($json_object);
@@ -98,7 +108,7 @@ function display_cff($atts) {
98
  foreach ($FBdata->data as $news ) {
99
 
100
  //Explode News and Page ID's into 2 values
101
- $StatusID = explode("_", $news->id);
102
 
103
  //Check whether it's a status (author comment or like)
104
  if ( ( $news->type == 'status' && !empty($news->message) ) || $news->type !== 'status' ) {
@@ -121,6 +131,7 @@ function display_cff($atts) {
121
  if (isset($title_limit) && $title_limit !== '') {
122
  if (strlen($story_text) > $title_limit) $story_text = substr($story_text, 0, $title_limit) . '...';
123
  }
 
124
  $content .= '<h4>' . $story_text . '</h4>';
125
  }
126
  if (!empty($news->message)) {
@@ -128,6 +139,7 @@ function display_cff($atts) {
128
  if (isset($title_limit) && $title_limit !== '') {
129
  if (strlen($message_text) > $title_limit) $message_text = substr($message_text, 0, $title_limit) . '...';
130
  }
 
131
  $content .= '<h4>' . $message_text . '</h4>';
132
  }
133
  if (!empty($news->description)) {
@@ -145,14 +157,39 @@ function display_cff($atts) {
145
 
146
  //Check whether it's a shared link
147
  if ($news->type == 'link') {
148
- $content .= '<a href="'.$news->link.'"><img src="'. $picture_b .'" border="0" style="padding-right:10px;" /></a>';
149
 
150
- //Display link name and description
151
- if (!empty($news->description)) {
152
- $content .= '<a href="'.$news->link.'">'. '<b>' . $news->name . '</b></a>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  }
154
- }
155
 
 
156
 
157
  //Show link
158
  if (!empty($news->link)) {
@@ -261,5 +298,9 @@ function cff_uninstall()
261
  delete_option( 'cff_body_length' );
262
  }
263
  register_uninstall_hook( __FILE__, 'cff_uninstall' );
 
 
 
 
264
 
265
  ?>
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.3.3
7
  Author: Smash Balloon
8
  Author URI: http://smashballoon.com/
9
  License: GPLv2 or later
30
  //Include admin
31
  include dirname( __FILE__ ) .'/custom-facebook-feed-admin.php';
32
 
 
 
33
  // Add shortcodes
34
  add_shortcode('custom-facebook-feed', 'display_cff');
35
  function display_cff($atts) {
62
  return false;
63
  }
64
 
65
+
 
 
 
 
 
 
 
66
 
67
+ //Get JSON object of feed data
68
+ function fetchUrl($url){
69
+ //Can we use cURL?
70
+ if(is_callable('curl_init')){
71
+ $ch = curl_init();
72
+ curl_setopt($ch, CURLOPT_URL, $url);
73
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
74
+ curl_setopt($ch, CURLOPT_TIMEOUT, 20);
75
+ curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
76
+
77
+ $feedData = curl_exec($ch);
78
+ curl_close($ch);
79
+
80
+ //If not then use file_get_contents
81
+ } elseif ( ini_get('allow_url_fopen') == 1 || ini_get('allow_url_fopen') === TRUE ) {
82
+ $feedData = @file_get_contents($url);
83
+
84
+ //Or else use the WP HTTP API
85
+ } else {
86
+ if( !class_exists( 'WP_Http' ) ) include_once( ABSPATH . WPINC. '/class-http.php' );
87
+ $request = new WP_Http;
88
+ $result = $request->request($url);
89
+ $feedData = $result['body'];
90
 
91
+ }
92
+
93
  return $feedData;
94
  }
95
 
96
+ //Get the contents of the Facebook page
97
+ $json_object = fetchUrl('https://graph.facebook.com/' . $page_id . '/posts?access_token=' . $access_token);
98
+
99
 
 
 
 
 
100
 
101
  //Interpret data with JSON
102
  $FBdata = json_decode($json_object);
108
  foreach ($FBdata->data as $news ) {
109
 
110
  //Explode News and Page ID's into 2 values
111
+ $PostID = explode("_", $news->id);
112
 
113
  //Check whether it's a status (author comment or like)
114
  if ( ( $news->type == 'status' && !empty($news->message) ) || $news->type !== 'status' ) {
131
  if (isset($title_limit) && $title_limit !== '') {
132
  if (strlen($story_text) > $title_limit) $story_text = substr($story_text, 0, $title_limit) . '...';
133
  }
134
+ $story_text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\" target='_blank'>\\0</a>", $story_text);
135
  $content .= '<h4>' . $story_text . '</h4>';
136
  }
137
  if (!empty($news->message)) {
139
  if (isset($title_limit) && $title_limit !== '') {
140
  if (strlen($message_text) > $title_limit) $message_text = substr($message_text, 0, $title_limit) . '...';
141
  }
142
+ $message_text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\" target='_blank'>\\0</a>", $message_text);
143
  $content .= '<h4>' . $message_text . '</h4>';
144
  }
145
  if (!empty($news->description)) {
157
 
158
  //Check whether it's a shared link
159
  if ($news->type == 'link') {
 
160
 
161
+ $story = $news->story;
162
+
163
+ //Check whether it's an event
164
+ $created_event = 'created an event.';
165
+ $shared_event = 'shared an event.';
166
+
167
+ if ( stripos($story, $created_event) !== false || stripos($story, $shared_event) !== false ){
168
+ //Get the event object
169
+ $eventID = $PostID[1];
170
+ //Get the contents of the event
171
+ $event_json = fetchUrl('https://graph.facebook.com/'.$eventID.'?access_token=' . $access_token);
172
+
173
+ //Interpret data with JSON
174
+ $event_object = json_decode($event_json);
175
+
176
+ //Display the event details
177
+ $content .= '<div class="details">';
178
+ if (!empty($event_object->name)) $content .= '<h5>' . $event_object->name . '</h5>';
179
+ if (!empty($event_object->location)) $content .= '<p>Where: ' . $event_object->location . '</p>';
180
+ if (!empty($event_object->start_time)) $content .= '<p>When: ' . date("F j, Y, g:i a", strtotime($event_object->start_time)) . '</p>';
181
+ if (!empty($event_object->description)){
182
+ $description = $event_object->description;
183
+ if (isset($body_limit) && $body_limit !== '') {
184
+ if (strlen($description) > $body_limit) $description = substr($description, 0, $body_limit) . '...';
185
+ }
186
+ $content .= '<p>' . $description . '</p>';
187
+ }
188
+
189
+ $content .= '</div><!-- end .details -->';
190
  }
 
191
 
192
+ }
193
 
194
  //Show link
195
  if (!empty($news->link)) {
298
  delete_option( 'cff_body_length' );
299
  }
300
  register_uninstall_hook( __FILE__, 'cff_uninstall' );
301
+
302
+
303
+ //Comment out the line below to view errors
304
+ error_reporting(0);
305
 
306
  ?>