Recent Facebook Posts - Version 1.6

Version Description

  • Improved code performance and readability
  • Improved usability of admin settings
  • Improved: cleaner HTML output
  • Improved: default CSS
  • Improved: image resizing
  • Improved: default settings
  • Added installation instructions link to admin settings
  • Added many CSS classes to output
  • Fixed extra double quote breaking link validation

Important: CSS Selectors and HTML output has changed in this version. If you're using custom styling rules you'll have to edit them after updating.

Download this release

Release Info

Developer DvanKooten
Plugin Icon wp plugin Recent Facebook Posts
Version 1.6
Comparing to
See all releases

Code changes from version 1.5.4 to 1.6

assets/css/default.css CHANGED
@@ -1,21 +1,25 @@
1
- .rfb_posts a.rfb_link{ display:block; clear:both; float:none; font-weight:normal; background:none; border:0; padding:1px 0; margin:0; cursor:pointer; text-decoration:none; font-size:11px; line-height:15px; height:15px; }
2
- .rfb_posts a.rfb_link:hover{ text-decoration:none; }
3
- .rfb_posts .rfb_text a{ word-break:break-all; }
4
- div.widget .rfb_posts .rfb_image a, .rfb_posts .rfb_image a{ border:1px solid #ccc; display:inline-block; margin:0; padding:3px; line-height:0; max-width:100%; }
5
- div.widget .rfb_posts .rfb_image a:hover, .rfb_posts .rfb_image a:hover{ border-color:#3b5998; }
6
- div.widget .rfb_posts .rfb_image img, .rfb_posts .rfb_image img{ max-width:100%; margin:0; padding:0; }
7
 
8
- .rfb_posts span.like_count, .rfb_posts span.comment_count{ margin-right:3px; background:url("../img/fb-sprite.png") no-repeat 0 0; padding-left:18px; color: #3B5998 !important; display:inline-block; }
9
- .rfb_posts span.like_count_and_comment_count:hover{ background-color: #ECEFF5; }
10
- .rfb_posts span.like_count{ background-position:0 -52px; }
11
- .rfb_posts span.comment_count{ background-position:0 -18px; }
12
- .rfb_posts span.timestamp{ color:#999; }
13
- .rfb_posts span.timestamp:hover span{ text-decoration:underline; }
14
- .rfb_posts span.like_count span{ display:none; }
15
- .rfb_posts span.comment_count span{ display:none; }
16
 
17
- /* shortcode */
18
- .rfb_posts.shortcode div.rfb-post{ border-bottom:1px solid #E9E9E9; padding-top:15px; margin-bottom:15px; margin-top:0; padding-bottom:0; }
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  /* widget */
21
- .widget .rfb_posts { }
1
+ .rfbp { }
 
 
 
 
 
2
 
3
+ .rfbp-post { border-bottom:1px solid #E9E9E9; padding-bottom:15px; margin-bottom:15px; margin-top:0; padding-top:0; }
4
+ .rfbp-post-link-wrap { margin-bottom:0 !important; padding-bottom:0; }
5
+ .rfbp-post-link{ display:block; font-weight:normal; background:none; border:0; padding:1px 0; margin:0; cursor:pointer; text-decoration:none !important; color:#3B5998;; font-size:11px; line-height:15px; height:15px; }
6
+ .rfbp-post-link:hover{ text-decoration:none !important; color:#3B5998; }
 
 
 
 
7
 
8
+ .rfbp-timestamp{ color:#999;}
9
+ .rfbp-timestamp:hover{ text-decoration:underline; color:#999; font-weight:normal; }
10
+
11
+ .rfbp-like-count, .rfbp-comment-count{ margin-right:3px; background:url("../img/fb-sprite.png") no-repeat 0 0; padding-left:18px; color: #3B5998; display:inline-block; }
12
+ .rfbp-like-count{ background-position:0 -52px; }
13
+ .rfbp-comment-count{ background-position:0 -18px; }
14
+ .rfbp-like-count > span{ display:none; }
15
+ .rfbp-comment-count > span{ display:none; }
16
+
17
+ .rfbp-image-wrap { margin:1em 0; max-width:100%; }
18
+ .rfbp-image-link{ margin:0; padding:0; float:none; line-height:0; max-width:100%; display:inline-block; }
19
+ .rfbp-image{ margin:0; padding:0; border:1px solid #ccc; }
20
+
21
+ .rfbp-text{ margin-top:0 !important; padding-top:0;}
22
+ .rfbp-text a{ word-break:break-all; }
23
 
24
  /* widget */
25
+ .rfbp-widget { }
includes/RFBP.php CHANGED
@@ -35,7 +35,8 @@ class RFBP {
35
  include_once RFBP_PLUGIN_DIR . 'includes/helper-functions.php';
36
  include_once RFBP_PLUGIN_DIR . 'includes/template-functions.php';
37
 
38
- add_shortcode('recent-facebook-posts', array($this, 'shortcode_output'));
 
39
 
40
  if($opts['load_css']) {
41
  add_action( 'wp_enqueue_scripts', array($this, 'load_css'));
@@ -54,7 +55,7 @@ class RFBP {
54
  }
55
 
56
  public function load_css() {
57
- wp_register_style('recent-facebook-posts-css', plugins_url('recent-facebook-posts/assets/css/default.css') );
58
  wp_enqueue_style('recent-facebook-posts-css' );
59
  }
60
 
@@ -65,13 +66,13 @@ class RFBP {
65
  'app_id' => '',
66
  'app_secret' => '',
67
  'fb_id' => 'DannyvanKootenCOM',
68
- 'cache_time' => 1800,
69
- 'load_css' => 0,
70
  'link_text' => 'Find us on Facebook',
71
  'link_new_window' => 0,
72
- 'img_size' => 'thumbnail',
73
- 'img_width' => 100,
74
- 'img_height' => 100
75
  );
76
 
77
  // get user options
@@ -98,7 +99,7 @@ class RFBP {
98
  self::$api = new Facebook(array(
99
  'appId' => trim($opts['app_id']),
100
  'secret' => trim($opts['app_secret']),
101
- ));
102
  }
103
 
104
  return self::$api;
@@ -239,95 +240,108 @@ class RFBP {
239
  return true;
240
  }
241
 
242
- public function shortcode_output($atts)
243
  {
244
  extract(shortcode_atts(array(
245
  'number' => '5',
246
  'likes' => 1,
247
  'comments' => 1,
248
- 'excerpt_length' => 140
 
 
 
249
  ), $atts));
250
 
251
  $opts = $this->get_settings();
252
  $posts = $this->get_posts();
253
- $posts = array_slice($posts, 0, $number);
254
 
255
- // set link target
256
- $link_target = ($opts['link_new_window']) ? "_blank" : '';
257
-
258
- $output = "\n<!-- Recent Facebook Posts v".RFBP_VERSION." - http://wordpress.org/plugins/recent-facebook-posts/ -->\n";
259
-
260
- $output .= '<div class="recent-facebook-posts rfb_posts shortcode">';
261
-
262
- foreach($posts as $post) {
263
- $content = $post['content'];
264
- $shortened = false;
265
-
266
- if(strlen($content) > $excerpt_length) {
267
- $limit = strpos($post['content'], ' ',$excerpt_length);
268
- if($limit) {
269
- $content = substr($post['content'], 0, $limit);
270
- $shortened = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  }
272
- }
273
-
274
 
275
- $output .= '<div class="rfb-post">';
276
- $output .= '<p class="rfb_text">'. nl2br(rfbp_make_clickable($content, $link_target));
277
- if ($shortened) $output .= '..';
278
- $output .= '</p>';
279
 
280
- if($opts['img_size'] != 'dont_show' && isset($post['image']) && $post['image']) {
281
-
282
- $img_atts = 'src="'. $post['image'] .'" style="max-width: '. $opts['img_width'] .'px; max-height: '. $opts['img_width'] .'px;"';
283
-
284
- $output .= '<p class="rfb_image"><a target="'.$link_target.'" href="'. $post['link'] . '" rel="nofollow"><img '. $img_atts .' alt="" /></a></p>';
285
- }
286
 
287
- $output .= '<p><a target="'.$link_target.'"" class="rfb_link" href="'. $post['link'] .'" rel="nofollow">';
288
- if($likes || $comments) { $output .= '<span class="like_count_and_comment_count">'; }
289
- if($likes) { $output .= '<span class="like_count">'. $post['like_count'] . ' <span>likes</span></span> '; }
290
- if($comments) { $output .= '<span class="comment_count">' . $post['comment_count'] . ' <span>comments</span></span> '; }
291
- if($likes || $comments) { $output .= '</span>'; }
292
- $output .= '<span class="timestamp" title="'. date('l, F j, Y', $post['timestamp']) . ' at ' . date('G:i', $post['timestamp']) . '" >';
293
- if($likes || $comments) { $output .= ' · '; }
294
- $output .= '<span>' . rfbp_time_ago($post['timestamp']) . '</span></span>';
295
- $output .= '</a></p></div>' ;
296
-
297
- }
298
-
299
- if(empty($posts)) {
300
- $output .= '<p>No recent Facebook status updates to show.</p>';
301
- if(current_user_can('manage_options')) {
302
- $output .= '<p><strong>Admins only notice:</strong> Did you <a href="' . get_admin_url(null,'options-general.php?page=rfb-settings') . '">configure the plugin</a> properly?</p>';
303
- }
304
  }
305
 
306
- $output .= "</div>";
307
- $output .= "\n <!-- / Recent Facebook Posts -->\n";
308
- return $output;
309
- }
310
 
311
- private function get_time_of_last_file_change($filePath)
312
- {
313
- clearstatcache();
314
- $time = filemtime($filePath);
315
 
316
- $isDST = (date('I', $time) == 1);
317
- $systemDST = (date('I') == 1);
318
 
319
- $adjustment = 0;
 
320
 
321
- if($isDST == false && $systemDST == true)
322
- $adjustment = 3600;
323
 
324
- else if($isDST == true && $systemDST == false)
325
- $adjustment = -3600;
326
 
327
- else
328
- $adjustment = 0;
329
 
330
- return ($time + $adjustment);
331
- }
332
-
333
- }
35
  include_once RFBP_PLUGIN_DIR . 'includes/helper-functions.php';
36
  include_once RFBP_PLUGIN_DIR . 'includes/template-functions.php';
37
 
38
+ add_shortcode('rfbp', array($this, 'output'));
39
+ add_shortcode('recent-facebook-posts', array($this, 'output'));
40
 
41
  if($opts['load_css']) {
42
  add_action( 'wp_enqueue_scripts', array($this, 'load_css'));
55
  }
56
 
57
  public function load_css() {
58
+ wp_register_style('recent-facebook-posts-css', plugins_url('recent-facebook-posts/assets/css/default.css'), array(), RFBP_VERSION );
59
  wp_enqueue_style('recent-facebook-posts-css' );
60
  }
61
 
66
  'app_id' => '',
67
  'app_secret' => '',
68
  'fb_id' => 'DannyvanKootenCOM',
69
+ 'cache_time' => 7200,
70
+ 'load_css' => 1,
71
  'link_text' => 'Find us on Facebook',
72
  'link_new_window' => 0,
73
+ 'img_size' => 'normal',
74
+ 'img_width' => '',
75
+ 'img_height' => ''
76
  );
77
 
78
  // get user options
99
  self::$api = new Facebook(array(
100
  'appId' => trim($opts['app_id']),
101
  'secret' => trim($opts['app_secret']),
102
+ ));
103
  }
104
 
105
  return self::$api;
240
  return true;
241
  }
242
 
243
+ public function output($atts = array())
244
  {
245
  extract(shortcode_atts(array(
246
  'number' => '5',
247
  'likes' => 1,
248
  'comments' => 1,
249
+ 'excerpt_length' => 140,
250
+ 'el' => 'div',
251
+ 'origin' => 'shortcode',
252
+ 'show_link' => false
253
  ), $atts));
254
 
255
  $opts = $this->get_settings();
256
  $posts = $this->get_posts();
 
257
 
258
+ ob_start();
259
+ ?>
260
+ <!-- Recent Facebook Posts v<?php echo RFBP_VERSION; ?> - http://wordpress.org/plugins/recent-facebook-posts/ -->
261
+ <div class="recent-facebook-posts rfbp rfbp-container rfbp-<?php echo $origin; ?>">
262
+ <?php
263
+
264
+ if($posts && !empty($posts)) {
265
+
266
+ $posts = array_slice($posts, 0, $number);
267
+ $link_target = ($opts['link_new_window']) ? "_blank" : '';
268
+
269
+ foreach($posts as $p) {
270
+ $content = $p['content'];
271
+ $shortened = false;
272
+
273
+ if(strlen($content) > $excerpt_length) {
274
+ $limit = strpos($p['content'], ' ',$excerpt_length);
275
+ if($limit) {
276
+ $content = substr($p['content'], 0, $limit);
277
+ $shortened = true;
278
+ }
279
+ }
280
+ ?>
281
+
282
+
283
+ <<?php echo $el; ?> class="rfbp-post">
284
+ <p class="rfbp-text"><?php echo nl2br(rfbp_make_clickable($content, $link_target)); if($shortened) { echo '..'; } ?></p>
285
+ <?php if($opts['img_size'] != 'dont_show' && isset($p['image']) && !empty($p['image'])) { ?>
286
+ <p class="rfbp-image-wrap">
287
+ <a class="rfbp-image-link" target="<?php echo $link_target; ?>" href="<?php echo $p['link']; ?>" rel="nofollow">
288
+ <?php $max_img_width = (!empty($opts['img_width'])) ? $opts['img_width'].'px' : '100%'; $max_img_height = (!empty($opts['img_height'])) ? $opts['img_height'].'px' : 'none'; ?>
289
+ <img class="rfbp-image" src="<?php echo $p['image']; ?>" style="max-width: <?php echo $max_img_width; ?>; max-height: <?php echo $max_img_height; ?>" alt="" />
290
+ </a>
291
+ </p>
292
+ <?php } ?>
293
+ <p class="rfbp-post-link-wrap">
294
+ <a target="<?php echo $link_target; ?>" class="rfbp-post-link" href="<?php echo $p['link']; ?>" rel="nofolloW">
295
+ <?php if($likes) { ?><span class="rfbp-like-count"><?php echo $p['like_count']; ?> <span>likes<?php if($comments) { ?>, <?php } ?></span></span><?php } ?>
296
+ <?php if($comments) { ?><span class="rfbp-comment-count"><?php echo $p['comment_count']; ?> <span>comments</span></span><?php } ?>
297
+ <?php if($likes || $comments) { ?> · <?php } ?>
298
+ <span class="rfbp-timestamp" title="<?php echo date('l, F j, Y', $p['timestamp']) ?> at <?php echo date('G:i', $p['timestamp']); ?>"><?php echo rfbp_time_ago($p['timestamp']); ?></span>
299
+ </a>
300
+ </p>
301
+ </<?php echo $el; ?>>
302
+ <?php
303
+
304
+ } // end foreach $posts
305
+ } else {
306
+ ?><p>No recent Facebook posts to show.</p><?php
307
+ if(current_user_can('manage_options')) {
308
+ ?><p><strong>Admins only notice:</strong> Did you <a href="<?php echo admin_url('options-general.php?page=rfb-settings'); ?>">configure the plugin</a> properly?</p><?php
309
  }
310
+ } ?>
 
311
 
312
+ <?php if($show_link) { ?>
313
+ <p class="rfbp-page-link-wrap"><a class="rfbp-page-link" href="http://www.facebook.com/<?php echo $opts['fb_id']; ?>/" rel="external nofollow" target="<?php echo $link_target; ?>"><?php echo strip_tags($opts['link_text']); ?></a></p>
314
+ <?php } ?>
 
315
 
316
+ </div>
317
+ <!-- / Recent Facebook Posts -->
318
+ <?php
319
+ $output = ob_get_contents();
320
+ ob_end_clean();
 
321
 
322
+ return $output;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  }
324
 
325
+ private function get_time_of_last_file_change($filePath)
326
+ {
327
+ clearstatcache();
328
+ $time = filemtime($filePath);
329
 
330
+ $isDST = (date('I', $time) == 1);
331
+ $systemDST = (date('I') == 1);
 
 
332
 
333
+ $adjustment = 0;
 
334
 
335
+ if($isDST == false && $systemDST == true)
336
+ $adjustment = 3600;
337
 
338
+ else if($isDST == true && $systemDST == false)
339
+ $adjustment = -3600;
340
 
341
+ else
342
+ $adjustment = 0;
343
 
344
+ return ($time + $adjustment);
345
+ }
346
 
347
+ }
 
 
 
includes/RFBP_Admin.php CHANGED
@@ -79,8 +79,9 @@ class RFBP_Admin {
79
  }
80
 
81
  $opts['cache_time'] = (int) $opts['cache_time'];
82
- $opts['img_height'] = (int) $opts['img_height'];
83
- $opts['img_width'] = (int) $opts['img_width'];
 
84
  return $opts;
85
  }
86
 
79
  }
80
 
81
  $opts['cache_time'] = (int) $opts['cache_time'];
82
+ $opts['img_height'] = (!empty($opts['img_height'])) ? (int) $opts['img_height'] : '';
83
+ $opts['img_width'] = (!empty($opts['img_width'])) ? (int) $opts['img_width'] : '';
84
+ $opts['load_css'] = (isset($opts['load_css'])) ? 1 : 0;
85
  return $opts;
86
  }
87
 
includes/RFBP_Widget.php CHANGED
@@ -6,9 +6,9 @@ class RFBP_Widget extends WP_Widget {
6
  'title' => 'Recent Facebook posts',
7
  'number_of_posts' => 5,
8
  'excerpt_length' => 140,
9
- 'show_comment_count' => false,
10
- 'show_like_count' => false,
11
- 'show_link' => false
12
  );
13
 
14
  public function __construct() {
@@ -24,10 +24,10 @@ class RFBP_Widget extends WP_Widget {
24
  $instance = array_merge($this->defaults, $instance);
25
  extract($instance);
26
 
27
- $rfb_options = RFBP::instance()->get_settings();
28
 
29
- if(empty($rfb_options['app_id'])) { ?>
30
- <p style="color:red;">You'll need to <a href="<?php echo get_admin_url(null, 'options-general.php?page=rfb-settings'); ?>">configure Recent Facebook Posts</a> first before this will work.</p>
31
  <?php } ?>
32
  <p>
33
  <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
@@ -45,12 +45,12 @@ class RFBP_Widget extends WP_Widget {
45
  </p>
46
 
47
  <p>
48
- <input type="checkbox" id="<?php echo $this->get_field_id( 'show_like_count' ); ?>" name="<?php echo $this->get_field_name( 'show_like_count' ); ?>" value="1" <?php if($show_like_count) { ?>checked="1"<?php } ?> />
49
  <label for="<?php echo $this->get_field_id( 'show_like_count' ); ?>"><?php _e( 'Show Like count?' ); ?></label>
50
  </p>
51
 
52
  <p>
53
- <input type="checkbox" id="<?php echo $this->get_field_id( 'show_comment_count' ); ?>" name="<?php echo $this->get_field_name( 'show_comment_count' ); ?>" value="1" <?php if($show_comment_count) { ?>checked="1"<?php } ?> />
54
  <label for="<?php echo $this->get_field_id( 'show_comment_count' ); ?>"><?php _e( 'Show Comment count?' ); ?></label>
55
  </p>
56
 
@@ -59,7 +59,7 @@ class RFBP_Widget extends WP_Widget {
59
  <label for="<?php echo $this->get_field_id( 'show_link' ); ?>"><?php _e( 'Show a link to Facebook page?' ); ?></label>
60
  </p>
61
 
62
- <p style="border: 2px solid green; font-weight:bold; background: #CFC; padding:5px; ">I spent countless hours developing (and offering support) for this plugin for FREE. If you like it, consider <a href="http://dannyvankooten.com/donate/">donating $10, $20 or $50</a> as a token of your appreciation.</p>
63
 
64
  <?php
65
  }
@@ -77,15 +77,6 @@ class RFBP_Widget extends WP_Widget {
77
 
78
  public function widget( $args, $instance = array()) {
79
 
80
- $opts = RFBP::instance()->get_settings();
81
- $posts = RFBP::instance()->get_posts();
82
-
83
- // slice posts to number set by user
84
- $posts = array_slice($posts, 0, $instance['number_of_posts']);
85
-
86
- // set link target
87
- $link_target = ($opts['link_new_window']) ? "_blank" : '';
88
-
89
  $instance = array_merge($this->defaults, $instance);
90
 
91
  extract($instance);
@@ -95,72 +86,16 @@ class RFBP_Widget extends WP_Widget {
95
 
96
  echo $before_widget;
97
  if ( ! empty( $title ) )
98
- echo $before_title . $title . $after_title; ?>
99
-
100
- <!-- Recent Facebook Posts v<?php echo RFBP_VERSION; ?> - http://wordpress.org/plugins/recent-facebook-posts/ -->
101
-
102
- <ul class="rfb_posts">
103
- <?php foreach($posts as $post) { ?>
104
- <?php
105
- $content = $post['content'];
106
- $shortened = false;
107
-
108
- if(strlen($content) > $instance['excerpt_length']) {
109
- $limit = strpos($post['content'], ' ',$instance['excerpt_length']);
110
- if($limit) {
111
- $content = substr($post['content'], 0, $limit);
112
- $shortened = true;
113
- }
114
- }
115
-
116
- ?>
117
- <li>
118
- <p class="rfb_text"><?php echo nl2br(rfbp_make_clickable($content, $link_target)); if($shortened) echo '..'; ?></p>
119
- <?php
120
- if($opts['img_size'] != 'dont_show' && isset($post['image']) && $post['image']) {
121
-
122
- if(isset($post['type']) && $post['type'] == 'photo') {
123
- $img_atts = "src=\"{$post['image']}\" style=\"width:auto; max-height: {$opts['img_height']}px;\"";
124
- } else {
125
- $img_atts = "src=\"{$post['image']}\" style=\"\"";
126
- }
127
- ?>
128
- <p class="rfb_image">
129
- <a target="<?php echo $link_target; ?>" href="<?php echo $post['link']; ?>" rel="nofollow">
130
-
131
- <img <?php echo $img_atts; ?> alt="" />
132
- </a>
133
- </p>
134
- <?php } ?>
135
-
136
-
137
- <p><a target="<?php echo $link_target; ?>" class="rfb_link" href="<?php echo $post['link']; ?>" rel="nofollow">
138
- <?php if($show_like_count || $show_comment_count) { ?><span class="like_count_and_comment_count"><?php } ?>
139
- <?php if($show_like_count) { ?><span class="like_count"><?php echo $post['like_count']; ?> <span>likes</span></span> <?php } ?>
140
- <?php if($show_comment_count) { ?><span class="comment_count"><?php echo $post['comment_count']; ?> <span>comments</span></span> <?php } ?>
141
- <?php if($show_like_count || $show_comment_count) { ?></span><?php } ?>
142
- <span class="timestamp" title="<?php echo date('l, F j, Y', $post['timestamp']) . ' at ' . date('G:i', $post['timestamp']); ?>" ><?php if($show_like_count || $show_comment_count) { ?> · <?php } ?><span><?php echo rfbp_time_ago($post['timestamp']); ?></span></span>
143
- </a></p>
144
- </li>
145
- <?php }
146
-
147
- if(empty($posts)) { ?>
148
- <li>
149
- <p>No recent Facebook status updates to show.</p>
150
- <?php if(current_user_can('manage_options')) { ?><p><strong>Admins only notice:</strong> Did you <a href="<?php echo admin_url('options-general.php?page=rfb-settings'); ?>">configure the plugin</a> properly?<?php } ?></p>
151
- </li>
152
-
153
- <?php } ?>
154
- </ul>
155
-
156
- <?php if($show_link) { ?>
157
- <p><a href="http://www.facebook.com/<?php echo $opts['fb_id']; ?>/" rel="external nofollow" target="<?php echo $link_target; ?>"><?php echo strip_tags($opts['link_text']); ?></a>.</p>
158
- <?php } ?>
159
-
160
- <!-- / Recent Facebook Posts -->
161
-
162
- <?php
163
-
164
  echo $after_widget;
165
  }
166
 
6
  'title' => 'Recent Facebook posts',
7
  'number_of_posts' => 5,
8
  'excerpt_length' => 140,
9
+ 'show_comment_count' => true,
10
+ 'show_like_count' => true,
11
+ 'show_link' => true
12
  );
13
 
14
  public function __construct() {
24
  $instance = array_merge($this->defaults, $instance);
25
  extract($instance);
26
 
27
+ $opts = RFBP::instance()->get_settings();
28
 
29
+ if(empty($opts['app_id'])) { ?>
30
+ <p style="color:red;">You'll need to <a href="<?php echo admin_url('options-general.php?page=rfb-settings'); ?>">configure Recent Facebook Posts</a> first before this will work.</p>
31
  <?php } ?>
32
  <p>
33
  <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
45
  </p>
46
 
47
  <p>
48
+ <input type="checkbox" id="<?php echo $this->get_field_id( 'show_like_count' ); ?>" name="<?php echo $this->get_field_name( 'show_like_count' ); ?>" value="1" <?php checked($show_like_count, 1); ?> />
49
  <label for="<?php echo $this->get_field_id( 'show_like_count' ); ?>"><?php _e( 'Show Like count?' ); ?></label>
50
  </p>
51
 
52
  <p>
53
+ <input type="checkbox" id="<?php echo $this->get_field_id( 'show_comment_count' ); ?>" name="<?php echo $this->get_field_name( 'show_comment_count' ); ?>" value="1" <?php checked($show_comment_count, 1); ?> />
54
  <label for="<?php echo $this->get_field_id( 'show_comment_count' ); ?>"><?php _e( 'Show Comment count?' ); ?></label>
55
  </p>
56
 
59
  <label for="<?php echo $this->get_field_id( 'show_link' ); ?>"><?php _e( 'Show a link to Facebook page?' ); ?></label>
60
  </p>
61
 
62
+ <p style="background: #222; color:#eee; padding:10px; ">I spent countless hours developing (and offering support) for this plugin for FREE. If you like it, consider <a href="http://dannyvankooten.com/donate/">donating $10, $20 or $50</a> as a token of your appreciation.</p>
63
 
64
  <?php
65
  }
77
 
78
  public function widget( $args, $instance = array()) {
79
 
 
 
 
 
 
 
 
 
 
80
  $instance = array_merge($this->defaults, $instance);
81
 
82
  extract($instance);
86
 
87
  echo $before_widget;
88
  if ( ! empty( $title ) )
89
+ echo $before_title . $title . $after_title;
90
+ echo RFBP::instance()->output(array(
91
+ 'origin' => 'widget',
92
+ 'number' => $number_of_posts,
93
+ 'likes' => $show_like_count,
94
+ 'comments' => $show_comment_count,
95
+ 'excerpt_length' => $excerpt_length,
96
+ 'el' => apply_filters('rfbp_widget_element', 'div'),
97
+ 'show_link' => $show_link
98
+ ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  echo $after_widget;
100
  }
101
 
includes/template-functions.php CHANGED
@@ -2,15 +2,5 @@
2
 
3
  function recent_facebook_posts($args = array())
4
  {
5
- $defaults = array(
6
- 'number' => '5',
7
- 'likes' => 1,
8
- 'comments' => 1,
9
- 'excerpt_length' => 140
10
- );
11
-
12
- $args = wp_parse_args($args, $defaults);
13
- extract($args);
14
-
15
- echo do_shortcode("[recent-facebook-posts number={$number} likes={$likes} comments={$comments} excerpt_length={$excerpt_length}]");
16
  }
2
 
3
  function recent_facebook_posts($args = array())
4
  {
5
+ echo RFBP::instance()->output($args);
 
 
 
 
 
 
 
 
 
 
6
  }
includes/views/settings_page.html.php CHANGED
@@ -54,18 +54,27 @@
54
  <table class="form-table">
55
  <tbody>
56
  <tr valign="top">
57
- <th scope="row"><label for="rfb_app_id" <?php if(empty($opts['app_id'])) echo 'class="error"'; ?>>Facebook App ID</label></th>
58
- <td><input type="text" class="widefat" id="rfb_app_id" name="rfb_settings[app_id]" value="<?php echo esc_attr($opts['app_id']); ?>" /></td>
 
 
 
59
  </tr>
60
 
61
  <tr valign="top">
62
  <th scope="row"><label for="rfb_app_secret" <?php if(empty($opts['app_secret'])) echo 'class="error"'; ?>>Facebook App Secret</label></th>
63
- <td><input type="text" class="widefat" id="rfb_app_secret" name="rfb_settings[app_secret]" value="<?php echo esc_attr($opts['app_secret']); ?>" /></td>
 
 
 
64
  </tr>
65
 
66
  <tr valign="top">
67
- <th scope="row"><label for="rfb_fb_id" <?php if(empty($opts['fb_id'])) echo 'class="error"'; ?>>Facebook page ID <small><a target="_blank" href="http://findmyfacebookid.com/">(use this)</a></small></label></th>
68
- <td><input type="text" class="widefat" id="rfb_fb_id" name="rfb_settings[fb_id]" value="<?php echo esc_attr($opts['fb_id']); ?>" /></td>
 
 
 
69
  </tr>
70
 
71
  <tr valign="top">
@@ -74,7 +83,7 @@
74
  </tr>
75
 
76
  <tr valign="top">
77
- <th scope="row"><label for="rfb_img_size">Image source size</label></th>
78
  <td>
79
  <select class="widefat" id="rfb_img_size" name="rfb_settings[img_size]">
80
  <option value="dont_show" <?php if($opts['img_size'] == 'dont_show') { echo 'selected'; } ?>>Don't show images</option>
@@ -88,20 +97,21 @@
88
  <th>Image dimensions<br /><small>(in pixels)</small></th>
89
  <td>
90
  <label style="float:left; margin-right:20px; ">
91
- Width<br />
92
  <input type="number" min="0" max="1600" size="3" id="rfb_img_width" name="rfb_settings[img_width]" value="<?php echo esc_attr($opts['img_width']); ?>" />
93
  </label>
94
- <label style="float:left;">
95
- Height<br />
96
  <input type="number" min="0" max="1600" size="3" id="rfb_img_height" name="rfb_settings[img_height]" value="<?php echo esc_attr($opts['img_height']); ?>" />
97
  </label>
 
98
  </td>
99
  </tr>
100
  </tbody>
101
  <tbody>
102
  <tr valign="top">
103
  <th scope="row"><label for="rfb_link_text">Link text</label></th>
104
- <td><input type="text" class="widefat" id="rfb_link_text" name="rfb_settings[link_text]" value="<?php echo esc_attr($opts['link_text']); ?>" /></td>
105
  </tr>
106
 
107
  <tr valign="top">
@@ -113,9 +123,7 @@
113
  <th scope="row"><label for="rfb_load_css">Load some default CSS?</label></th>
114
  <td><input type="checkbox" id="rfb_load_css" name="rfb_settings[load_css]" value="1" <?php checked($opts['load_css'], 1); ?> /></td>
115
  </tr>
116
-
117
  </tbody>
118
-
119
  </table>
120
 
121
  <p class="submit">
@@ -175,6 +183,16 @@
175
  <div class="rfbp-box">
176
  <h3>Looking for support?</h3>
177
  <p>Having trouble? Please use the <a href="http://wordpress.org/support/plugin/recent-facebook-posts">support forums</a> on WordPress.org.</p>
 
 
 
 
 
 
 
 
 
 
178
  </div>
179
 
180
  <div class="rfbp-box">
54
  <table class="form-table">
55
  <tbody>
56
  <tr valign="top">
57
+ <th scope="row"><label for="rfb_app_id" <?php if(empty($opts['app_id'])) echo 'class="error"'; ?>>Facebook App ID/API Key</label></th>
58
+ <td>
59
+ <input type="text" class="widefat" placeholder="Eg: 123456789012345" id="rfb_app_id" name="rfb_settings[app_id]" value="<?php echo esc_attr($opts['app_id']); ?>" />
60
+ <small class="help"><a href="https://developers.facebook.com/apps">get from developers.facebook.com/apps</a></small>
61
+ </td>
62
  </tr>
63
 
64
  <tr valign="top">
65
  <th scope="row"><label for="rfb_app_secret" <?php if(empty($opts['app_secret'])) echo 'class="error"'; ?>>Facebook App Secret</label></th>
66
+ <td>
67
+ <input type="text" class="widefat" placeholder="Eg: 16vgrz4hk45wvh29k2puk45wvk2h29pu" id="rfb_app_secret" name="rfb_settings[app_secret]" value="<?php echo esc_attr($opts['app_secret']); ?>" />
68
+ <small class="help"><a href="https://developers.facebook.com/apps">get from developers.facebook.com/apps</a></small>
69
+ </td>
70
  </tr>
71
 
72
  <tr valign="top">
73
+ <th scope="row"><label for="rfb_fb_id" <?php if(empty($opts['fb_id'])) echo 'class="error"'; ?>>Facebook Page ID</label></th>
74
+ <td>
75
+ <input type="text" class="widefat" placeholder="Eg: DannyvanKootenCOM" id="rfb_fb_id" name="rfb_settings[fb_id]" value="<?php echo esc_attr($opts['fb_id']); ?>" />
76
+ <small><a target="_blank" href="http://findmyfacebookid.com/">Use this tool to find the numeric ID of the Facebook page you want to fetch posts from</a></small>
77
+ </td>
78
  </tr>
79
 
80
  <tr valign="top">
83
  </tr>
84
 
85
  <tr valign="top">
86
+ <th scope="row"><label for="rfb_img_size">Image size</label></th>
87
  <td>
88
  <select class="widefat" id="rfb_img_size" name="rfb_settings[img_size]">
89
  <option value="dont_show" <?php if($opts['img_size'] == 'dont_show') { echo 'selected'; } ?>>Don't show images</option>
97
  <th>Image dimensions<br /><small>(in pixels)</small></th>
98
  <td>
99
  <label style="float:left; margin-right:20px; ">
100
+ Max Width<br />
101
  <input type="number" min="0" max="1600" size="3" id="rfb_img_width" name="rfb_settings[img_width]" value="<?php echo esc_attr($opts['img_width']); ?>" />
102
  </label>
103
+ <label style="float:left; margin-right:20px;">
104
+ Max Height<br />
105
  <input type="number" min="0" max="1600" size="3" id="rfb_img_height" name="rfb_settings[img_height]" value="<?php echo esc_attr($opts['img_height']); ?>" />
106
  </label>
107
+ <small class="help"><br />Leave empty for default sizing (maximum of 100% of containing element)</small>
108
  </td>
109
  </tr>
110
  </tbody>
111
  <tbody>
112
  <tr valign="top">
113
  <th scope="row"><label for="rfb_link_text">Link text</label></th>
114
+ <td><input type="text" class="widefat" placeholder="Find us on Facebook" id="rfb_link_text" name="rfb_settings[link_text]" value="<?php echo esc_attr($opts['link_text']); ?>" /></td>
115
  </tr>
116
 
117
  <tr valign="top">
123
  <th scope="row"><label for="rfb_load_css">Load some default CSS?</label></th>
124
  <td><input type="checkbox" id="rfb_load_css" name="rfb_settings[load_css]" value="1" <?php checked($opts['load_css'], 1); ?> /></td>
125
  </tr>
 
126
  </tbody>
 
127
  </table>
128
 
129
  <p class="submit">
183
  <div class="rfbp-box">
184
  <h3>Looking for support?</h3>
185
  <p>Having trouble? Please use the <a href="http://wordpress.org/support/plugin/recent-facebook-posts">support forums</a> on WordPress.org.</p>
186
+ <p>Take a close look at the <a href="http://wordpress.org/plugins/recent-facebook-posts/installation/">installation instructions</a> for help configuring the plugin and registering your own Facebook application (required).</p>
187
+ </div>
188
+
189
+ <div class="rfbp-box">
190
+ <h3>Other Useful plugins</h3>
191
+ <ul class="ul-square">
192
+ <li><a href="http://wordpress.org/plugins/mailchimp-for-wp/">MailChimp for WordPress</a></li>
193
+ <li><a href="http://wordpress.org/plugins/wysiwyg-widgets/">WYSIWYG Widgets</a>
194
+ <li><a href="http://wordpress.org/plugins/newsletter-sign-up/">Newsletter Sign-Up</a></li>
195
+ </ul>
196
  </div>
197
 
198
  <div class="rfbp-box">
readme.txt CHANGED
@@ -3,16 +3,16 @@ Contributors: DvanKooten
3
  Donate link: http://dannyvankooten.com/donate/
4
  Tags: facebook,posts,fanpage,recent posts,fb,like box alternative,widget,facebook widget,widgets,facebook updates,like button,fb posts
5
  Requires at least: 3.1
6
- Tested up to: 3.6
7
- Stable tag: 1.5.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Lists most recent Facebook posts from public pages. A faster, prettier and more customizable alternative to Facebooks Like Box.
12
 
13
  == Description ==
14
 
15
- This plugin adds a widget and a shortcode `[recent-facebook-posts]` to your WordPress website which you can use to list your most recent Facebook posts. This plugin works with public pages and to a certain extent with personal profiles.
16
 
17
  **Features**
18
 
@@ -32,20 +32,33 @@ There is a demo on [my own website](http://dannyvankooten.com/), I use the plugi
32
 
33
  == Installation ==
34
 
35
- 1. Upload the contents of the .zip-file to your plugins directory
 
 
36
  1. Activate the plugin through the 'Plugins' menu in WordPress
 
 
 
 
37
  1. If you're not a Facebook developer yet, register as one [here](http://developers.facebook.com/apps).
38
- 1. [Create a new Facebook application](http://developers.facebook.com/apps). Fill in ANY valid name but leave the namespace field blank and the hosting checkbox unchecked.
39
- 1. In the Basic Application settings screen, scroll down a bit and select "Website with Facebook login" and set your `Site URL` to the URL of your WordPress installation. Example: `http://dannyvankooten.com/`
40
- 1. (optional) Fill in the App Domain field as well. Example: `dannyvankooten.com`
41
- 1. Open a new browser tab and go to your WordPress admin panel. Open the Recent FB Posts settings screen.
42
- 1. Copy paste your Facebook `App id` and `App Secret` into the setting fields. [screenshot 1](http://wordpress.org/extend/plugins/recent-facebook-posts/screenshots/)
 
 
43
  1. Find the numeric Facebook ID of your public Facebook page using [this website](http://findmyfacebookid.com/).
44
- 1. Fill in your Facebook ID in the RFB options screen.
45
- 1. Try to connect the plugin to Facebook by clicking the "Get access token" button.
46
- 1. Test if everything works by clicking the "Renew cache" button.
 
47
 
48
- If you're still in doubt, have a look at the [screenshots](http://wordpress.org/extend/plugins/recent-facebook-posts/screenshots/).
 
 
 
 
49
 
50
  == Frequently Asked Questions ==
51
 
@@ -77,14 +90,16 @@ Yes, you can use the `[recent-facebook-posts]` shortcode. Optionally, add the fo
77
  likes = 1 // show like count, 1 = yes, 0 = no
78
  comments = 1 // show comment count, 1 = yes, 0 = no
79
  excerpt_length = 140 // the number of characters to show from each post
80
- number = 5 // number of posts to show
 
 
81
  `
82
 
83
  *Shortcode example*
84
- `[recent-facebook-posts number=10 likes=1 comments=1 excerpt_length=250]`
85
 
86
  = What about usage of your plugin in template files? =
87
- Use `<?php recent-facebook-posts(array('likes' => 1, 'excerpt_length => 140')); ?>` in your theme files. The parameter is optional, it can be an array of the same values available for the shortcode.
88
 
89
  == Screenshots ==
90
 
@@ -92,6 +107,19 @@ Use `<?php recent-facebook-posts(array('likes' => 1, 'excerpt_length => 140'));
92
  2. The green circled fields are the fields where you'll need to provide your Facebook app id and app secret (as shown in screenshot 1).
93
 
94
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  = 1.5.3 =
96
  * Improved: Code improvement
97
  * Improved: UI improvement, implemented some HTML5 fields
@@ -192,3 +220,7 @@ Use `<?php recent-facebook-posts(array('likes' => 1, 'excerpt_length => 140'));
192
  = 0.1 =
193
  * Initial release
194
 
 
 
 
 
3
  Donate link: http://dannyvankooten.com/donate/
4
  Tags: facebook,posts,fanpage,recent posts,fb,like box alternative,widget,facebook widget,widgets,facebook updates,like button,fb posts
5
  Requires at least: 3.1
6
+ Tested up to: 3.6.1
7
+ Stable tag: 1.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Lists most recent Facebook posts from public Facebook pages. A faster, prettier and more customizable alternative to Facebooks Like Box.
12
 
13
  == Description ==
14
 
15
+ This plugin adds a widget, a shortcode `[recent-facebook-posts]` and a template function `recent_facebook_posts()` to your WordPress website which you can use to list your most recent Facebook posts. This plugin works with public pages and to a certain extent with personal profiles (YMMV with the latter).
16
 
17
  **Features**
18
 
32
 
33
  == Installation ==
34
 
35
+ = Installing the plugin =
36
+ 1. [Download the latest version of the plugin](http://downloads.wordpress.org/plugin/recent-facebook-posts.zip)
37
+ 1. Upload the contents of the downloaded .zip-file to your WordPress plugin directory
38
  1. Activate the plugin through the 'Plugins' menu in WordPress
39
+
40
+ = Registering a Facebook application =
41
+ This plugin requires a Facebook application to fetch posts from Facebook.
42
+
43
  1. If you're not a Facebook developer yet, register as one [here](http://developers.facebook.com/apps).
44
+ 1. [Create a new Facebook application](http://developers.facebook.com/apps). Fill in ANY name you like but leave the `namespace` field blank and the `hosting` checkbox unchecked.
45
+ 1. In the Basic Application settings screen, scroll down a bit and select `Website with Facebook login` and set your `Site URL` to the URL of your WordPress installation, eg `http://dannyvankooten.com/`
46
+ 1. *(optional)* Fill in the App Domain field as well, eg `dannyvankooten.com` *(no http:// prefix)*
47
+
48
+ = Configuring the plugin =
49
+ 1. Go to *Settings > Recent Facebook* posts in your WP Admin panel.
50
+ 1. Copy and paste your Facebook `App ID/API Key` and `App Secret` into the setting fields. [screenshot 1](http://wordpress.org/extend/plugins/recent-facebook-posts/screenshots/)
51
  1. Find the numeric Facebook ID of your public Facebook page using [this website](http://findmyfacebookid.com/).
52
+ 1. Copy paste the ID in the `Facebook Page ID` field.
53
+ 1. Try to connect the plugin to Facebook by clicking the "Get access token" button. You will be redirected to Facebook.
54
+ 1. Test if fetching posts works by clicking the "Renew cache" button.
55
+ 1. Add `[recent-facebook-posts]` to the page where you would like to show a list of recent Facebook posts or use the widget.
56
 
57
+ = Extra notes =
58
+ * Your Site URL should match your WordPress url exactly. Include any subdomains in the URL and don't include subfolders.
59
+ * The plugin works with personal profiles, but only to a certain extend. I am not actively supporting personal profiles because of many privacy settings related issues.
60
+
61
+ If you're still in doubt, have a look at the [screenshots](http://wordpress.org/extend/plugins/recent-facebook-posts/screenshots/) and the [FAQ](http://wordpress.org/plugins/recent-facebook-posts/faq/) for solutions to common mistakes.
62
 
63
  == Frequently Asked Questions ==
64
 
90
  likes = 1 // show like count, 1 = yes, 0 = no
91
  comments = 1 // show comment count, 1 = yes, 0 = no
92
  excerpt_length = 140 // the number of characters to show from each post
93
+ number = 5 // number of posts to show,
94
+ show_link = 0 // show a link to Facebook page after posts?
95
+ el = div // which element to use as a post container?
96
  `
97
 
98
  *Shortcode example*
99
+ `[recent-facebook-posts number=10 likes=1 comments=1 excerpt_length=250 show_link=1]`
100
 
101
  = What about usage of your plugin in template files? =
102
+ Use `<?php recent_facebook_posts(array('likes' => 1, 'excerpt_length => 140')); ?>` in your theme files. The parameter is optional, it can be an array of the same values available for the shortcode.
103
 
104
  == Screenshots ==
105
 
107
  2. The green circled fields are the fields where you'll need to provide your Facebook app id and app secret (as shown in screenshot 1).
108
 
109
  == Changelog ==
110
+ = 1.6 =
111
+ * Improved code performance and readability
112
+ * Improved usability of admin settings
113
+ * Improved: cleaner HTML output
114
+ * Improved: default CSS
115
+ * Improved: image resizing
116
+ * Improved: default settings
117
+ * Added installation instructions link to admin settings
118
+ * Added many CSS classes to output
119
+ * Fixed extra double quote breaking link validation
120
+
121
+ **Important:** CSS Selectors and HTML output has changed in this version. If you're using custom styling rules you'll have to edit them after updating.
122
+
123
  = 1.5.3 =
124
  * Improved: Code improvement
125
  * Improved: UI improvement, implemented some HTML5 fields
220
  = 0.1 =
221
  * Initial release
222
 
223
+ == Upgrade Notice ==
224
+
225
+ = 1.6 =
226
+ CSS and HTML output have changed. If you're using custom CSS styles you will have to edit them after updating.
recent-facebook-posts.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Recent Facebook Posts
4
  Plugin URI: http://dannyvankooten.com/wordpress-plugins/recent-facebook-posts/
5
  Description: Lists most recent posts from a public Facebook page.
6
- Version: 1.5.4
7
  Author: Danny van Kooten
8
  Author URI: http://dannyvankooten.com/
9
  License: GPL2
@@ -25,7 +25,7 @@ License: GPL2
25
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
  */
27
 
28
- define("RFBP_VERSION", "1.5.4");
29
  define("RFBP_PLUGIN_DIR", plugin_dir_path(__FILE__));
30
 
31
  // define WP_CONTENT_DIR since we're using it..
3
  Plugin Name: Recent Facebook Posts
4
  Plugin URI: http://dannyvankooten.com/wordpress-plugins/recent-facebook-posts/
5
  Description: Lists most recent posts from a public Facebook page.
6
+ Version: 1.6
7
  Author: Danny van Kooten
8
  Author URI: http://dannyvankooten.com/
9
  License: GPL2
25
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
  */
27
 
28
+ define("RFBP_VERSION", "1.6");
29
  define("RFBP_PLUGIN_DIR", plugin_dir_path(__FILE__));
30
 
31
  // define WP_CONTENT_DIR since we're using it..