Custom Facebook Feed - Version 2.7

Version Description

  • New: Now easily get your own Access Token to avoid any Facebook connection issues. Simply click the blue "Log in and get my Access Token" button on the plugin's settings page and connect your Facebook account to get your token. The Access Token will work to get posts from ANY Facebook page. Thanks to our friends at SlickRemix for powering our new login and getting the plugin back up and running again!
  • Tweak: Removed the minimum caching time if you're using your own Page Access Token
Download this release

Release Info

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

Code changes from version 2.6.4 to 2.7

README.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: smashballoon
3
Tags: Facebook, Facebook feed, Facebook posts, Facebook wall, Facebook page
4
Requires at least: 3.0
5
Tested up to: 4.9
6
- Stable tag: 2.6.4
7
License: GPLv2 or later
8
License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
@@ -265,6 +265,10 @@ You no longer need your own Access Token to use the Custom Facebook Feed Plugin,
265
266
== Changelog ==
267
268
= 2.6.4 =
269
* **Important:** If you are displaying posts from a Facebook page that **you are an admin of** then it is now highly recommended that you retrieve your own Access Token for that page to avoid any API rate limit errors. Simply follow these [step-by-step](https://smashballoon.com/custom-facebook-feed/page-token/) instructions to obtain one.
270
3
Tags: Facebook, Facebook feed, Facebook posts, Facebook wall, Facebook page
4
Requires at least: 3.0
5
Tested up to: 4.9
6
+ Stable tag: 2.7
7
License: GPLv2 or later
8
License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
265
266
== Changelog ==
267
268
+ = 2.7 =
269
+ * New: Now easily get your own Access Token to avoid any Facebook connection issues. Simply click the blue "Log in and get my Access Token" button on the plugin's settings page and connect your Facebook account to get your token. The Access Token will work to get posts from ANY Facebook page. Thanks to our friends at SlickRemix for powering our new login and getting the plugin back up and running again!
270
+ * Tweak: Removed the minimum caching time if you're using your own Page Access Token
271
+
272
= 2.6.4 =
273
* **Important:** If you are displaying posts from a Facebook page that **you are an admin of** then it is now highly recommended that you retrieve your own Access Token for that page to avoid any API rate limit errors. Simply follow these [step-by-step](https://smashballoon.com/custom-facebook-feed/page-token/) instructions to obtain one.
274
css/cff-admin-style.css CHANGED
@@ -127,8 +127,8 @@
127
color: #592626;
128
}
129
#cff-admin .cff-success{
130
- background: #f7faf1;
131
- border: 1px solid #5c783e;
132
color: #3e5f1c;
133
}
134
/* Loader */
@@ -797,4 +797,142 @@
797
margin-top: 10px;
798
border: 1px solid #ddd;
799
display: none;
800
}
127
color: #592626;
128
}
129
#cff-admin .cff-success{
130
+ background: #dceada;
131
+ border: 1px solid #6ca365;
132
color: #3e5f1c;
133
}
134
/* Loader */
797
margin-top: 10px;
798
border: 1px solid #ddd;
799
display: none;
800
+ }
801
+
802
+ /* FB login button */
803
+ #cff-admin .cff_admin_btn,
804
+ #cff-admin #cff_admin_cancel_btn{
805
+ display: inline-block;
806
+ clear: both;
807
+ padding: 0 21px 0 20px;
808
+ height: 45px;
809
+ line-height: 44px;
810
+ background: #386793;
811
+ color: #e9eef3;
812
+ text-decoration: none;
813
+ font-size: 14px;
814
+
815
+ -moz-border-radius: 5px;
816
+ -webkit-border-radius: 5px;
817
+ border-radius: 5px;
818
+
819
+ -moz-transition: all 0.5s ease-in-out;
820
+ -webkit-transition: all 0.5s ease-in-out;
821
+ -o-transition: all 0.5s ease-in-out;
822
+ transition: all 0.5s ease-in-out;
823
+ }
824
+ #cff-admin .cff_admin_btn:hover,
825
+ #cff-admin #cff_admin_cancel_btn:hover{
826
+ background-color: #3880c4;
827
+ color: #fff;
828
+
829
+ -moz-transition: all 0.1s ease-in-out;
830
+ -webkit-transition: all 0.1s ease-in-out;
831
+ -o-transition: all 0.1s ease-in-out;
832
+ transition: all 0.1s ease-in-out;
833
+ }
834
+ #cff-admin .cff_admin_btn .fa {
835
+ margin-right: 5px;
836
+ font-size: 18px;
837
+ position: relative;
838
+ top: 1px;
839
+ }
840
+
841
+ #cff-admin .cff-managed-pages{
842
+ margin: 10px 0 0 0;
843
+ }
844
+ #cff-admin .cff-managed-page{
845
+ width: 100%;
846
+ border: 1px solid transparent;
847
+ padding: 0;
848
+ background: #fff;
849
+ box-sizing: border-box;
850
+ }
851
+ #cff-admin .cff-managed-page:hover{
852
+ background: rgba(255,255,255,0.8);
853
+ border: 1px solid #ccc;
854
+ cursor: pointer;
855
+ }
856
+ #cff-admin .cff-managed-page .cff-page-avatar{
857
+ float: left;
858
+ margin-right: 10px;
859
+ }
860
+ #cff-admin .cff-managed-page p{
861
+ padding: 0;
862
+ margin: 0;
863
+ height: 50px;
864
+ line-height: 50px;
865
+ }
866
+ #cff-admin .cff-managed-page.cff-page-selected{
867
+ background: #dceada;
868
+ border: 1px solid #6ca365;
869
+ }
870
+ #cff-admin .cff-save-page-token{
871
+ display: none;
872
+ }
873
+
874
+ #cff-admin #cff-enter-manual-id{
875
+ /*display: none;*/
876
+ }
877
+ #cff-admin .cff-reviews-access-token{
878
+ /*display: none !important;*/
879
+ }
880
+ #cff-admin #cff_fb_login_modal{
881
+ display: none;
882
+ position: fixed;
883
+ z-index: 999;
884
+ width: 100%;
885
+ top: 0;
886
+ right: 0;
887
+ bottom: 0;
888
+ left: 0;
889
+ background: rgba(0,0,0,0.3);
890
+ }
891
+ #cff-admin .cff_modal_box{
892
+ position: absolute;
893
+ top: 180px;
894
+ left: 50%;
895
+ width: 380px;
896
+ margin: 0 0 0 -195px;
897
+ padding: 20px 40px;
898
+ background: #fff;
899
+ text-align: center;
900
+ -webkit-box-shadow: 0 1px 20px rgba(0,0,0,0.2);
901
+ box-shadow: 0 1px 20px rgba(0,0,0,0.2);
902
+ -moz-border-radius: 3px;
903
+ -webkit-border-radius: 3px;
904
+ border-radius: 3px;
905
+ }
906
+ #cff-admin .cff_modal_box .cff_admin_btn{
907
+ margin-top: 10px;
908
+ }
909
+ #cff-admin #cff_admin_cancel_btn{
910
+ margin-right: 5px;
911
+ background: #ddd;
912
+ color: #555;
913
+ }
914
+ #cff-admin #cff_admin_cancel_btn:hover{
915
+ background: #ccc;
916
+ color: #333;
917
+ }
918
+ #cff-admin .cff_srlogo{
919
+ display: inline-block;
920
+ height: 16px;
921
+ }
922
+ #cff-admin .cff_srlogo {
923
+ display: inline-block;
924
+ height: 16px;
925
+ font-weight: bold;
926
+ font-size: 16px;
927
+ margin-top: -5px;
928
+ }
929
+ #cff-admin .cff_srlogo img {
930
+ height: 16px;
931
+ position: relative;
932
+ top: 2px;
933
+ left: -2px;
934
+ }
935
+ #cff-admin .cff_modal_box p{
936
+ font-size: 14px;
937
+ line-height: 1.6;
938
}
custom-facebook-feed-admin.php CHANGED
@@ -123,7 +123,7 @@ function cff_settings_page() {
123
<a href="?page=cff-top&amp;tab=support" class="nav-tab <?php echo $cff_active_tab == 'support' ? 'nav-tab-active' : ''; ?>"><?php _e('Support', 'custom-facebook-feed'); ?></a>
124
</h2>
125
126
- <?php if( $cff_active_tab == 'configuration' ) { //Start Extensions tab ?>
127
128
<form name="form1" method="post" action="">
129
<input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
@@ -131,6 +131,68 @@ function cff_settings_page() {
131
132
<br />
133
<h3><?php _e('Configuration', 'custom-facebook-feed'); ?></h3>
134
<table class="form-table">
135
<tbody>
136
<tr valign="top">
@@ -167,17 +229,17 @@ function cff_settings_page() {
167
</tr> -->
168
169
<tr valign="top">
170
- <th scope="row" style="padding-bottom: 10px;"><?php _e('Enter my own Access Token', 'custom-facebook-feed'); ?><br /><i style="font-weight: normal; font-size: 12px; color: red;"><?php _e('Highly Recommended', 'custom-facebook-feed'); ?></i></th>
171
<td>
172
<input name="cff_show_access_token" type="checkbox" id="cff_show_access_token" <?php if($show_access_token_val == true) echo "checked"; ?> />&nbsp;<a class="cff-tooltip-link" href="JavaScript:void(0);"><?php _e("What is this?", 'custom-facebook-feed'); ?></a>
173
- <p class="cff-tooltip cff-more-info"><?php _e("If you are displaying posts from a Facebook page that <b><u>you are an admin of</u></b> then it is highly recommended that you retrieve your own Access Token for that page to avoid any API rate limit errors. Simply follow these <a href='https://smashballoon.com/custom-facebook-feed/page-token/' target='_blank'>step-by-step instructions</a> to obtain one.", 'custom-facebook-feed'); ?></p>
174
</td>
175
</tr>
176
177
<tr valign="top" class="cff-access-token-hidden">
178
<th scope="row" style="padding-bottom: 10px;"><?php _e('Facebook Access Token', 'custom-facebook-feed'); ?></th>
179
<td>
180
- <input name="cff_access_token" id="cff_access_token" type="text" value="<?php esc_attr_e( $access_token_val, 'custom-facebook-feed' ); ?>" size="45" />
181
182
<div class="cff-notice cff-profile-error cff-access-token">
183
<?php _e("<p>This doesn't appear to be an Access Token. Please be sure that you didn't enter your App Secret instead of your Access Token.<br />Your App ID and App Secret are used to obtain your Access Token; simply paste them into the fields in the last step of the <a href='https://smashballoon.com/custom-facebook-feed/access-token/' target='_blank'>Access Token instructions</a> and click '<b>Get my Access Token</b>'.</p>", 'custom-facebook-feed'); ?>
123
<a href="?page=cff-top&amp;tab=support" class="nav-tab <?php echo $cff_active_tab == 'support' ? 'nav-tab-active' : ''; ?>"><?php _e('Support', 'custom-facebook-feed'); ?></a>
124
</h2>
125
126
+ <?php if( $cff_active_tab == 'configuration' ) { //Start tab ?>
127
128
<form name="form1" method="post" action="">
129
<input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
131
132
<br />
133
<h3><?php _e('Configuration', 'custom-facebook-feed'); ?></h3>
134
+
135
+
136
+ <div id="cff_fb_login_modal">
137
+ <div class="cff_modal_box">
138
+ <p>We're teaming up with our good friends at <span class="cff_srlogo">SlickRemix</b> <img src="<?php echo plugins_url( 'img/slick-remix.png' , __FILE__ ) ?>"></span> to provide you with an easy way to connect to Facebook. Simply log into your Facebook account using the button below and approve the plugin to connect your account.</p>
139
+
140
+ <p><a href="javascript:void(0);" id="cff_admin_cancel_btn">Cancel</a>
141
+
142
+ <a href="https://www.facebook.com/dialog/oauth?scope=manage_pages&client_id=1123168491105924&redirect_uri=https://www.slickremix.com/facebook-token/&state=<?php echo admin_url('admin.php?page=cff-top'); ?>" class="cff_admin_btn"><i class="fa fa-facebook-square"></i> <?php _e( 'Continue', 'custom-facebook-feed' ); ?></a></p>
143
+
144
+ <p style="font-size: 11px; margin-top: 25px;"><b>Please note:</b> this does not give us permission to manage your Facebook pages, it simply allows the plugin to see a list of the pages you manage and retrieve an Access Token.</p>
145
+ </div>
146
+ </div>
147
+
148
+ <a href="JavaScript:void(0);" class="cff_admin_btn" id="cff_fb_login"><i class="fa fa-facebook-square"></i> <?php _e( 'Log in and get my Access Token', 'custom-facebook-feed' ); ?></a>
149
+
150
+
151
+ <?php
152
+ if( isset($_GET['access_token']) && isset($_GET['final_response']) ){
153
+
154
+ if( $_GET['final_response'] == 'true' ){
155
+
156
+ $access_token = $_GET['access_token'];
157
+ $url = 'https://graph.facebook.com/me/accounts?limit=500&access_token='.$access_token;
158
+ $pages_data = @file_get_contents($url);
159
+ $pages_data_arr = json_decode($pages_data);
160
+
161
+ echo '<div class="cff-managed-pages">';
162
+
163
+ if( empty($pages_data_arr->data) ){
164
+ //If they don't manage any pages then just use the user token instead
165
+ ?>
166
+ <script type='text/javascript'>
167
+ jQuery(document).ready(function($) {
168
+ $('#cff_access_token').val('<?php echo $access_token ?>').addClass('cff-success');
169
+ //Check the own access token setting so it reveals token field
170
+ if( $('#cff_show_access_token:checked').length < 1 ){
171
+ $("#cff_show_access_token").trigger("change").prop( "checked", true );
172
+ }
173
+ });
174
+ </script>
175
+
176
+ <?php
177
+ } else {
178
+ //Show the pages they manage
179
+ echo '<p style="background: #dceada; border: 1px solid #6ca365; padding: 15px 20px; border-radius: 5px;">Select one of the pages below to get an Access Token.<br /><b><u>Important:</u> This Access Token will allow you to display posts from <u>any</u> public Facebook page, not just the one selected.</b></p>';
180
+
181
+ foreach ( $pages_data_arr->data as $page => $page_data ) {
182
+ echo '<div class="cff-managed-page ';
183
+ if( $page_data->id == $page_id_val ) echo 'cff-page-selected';
184
+ echo '" data-token="'.$page_data->access_token.'" data-page-id="'.$page_data->id.'">';
185
+ echo '<p><img class="cff-page-avatar" border="0" height="50" width="50" src="https://graph.facebook.com/'.$page_data->id.'/picture"><b>'.$page_data->name.'</b> &nbsp; (Page ID: '.$page_data->id.')</p>';
186
+ echo '</div>';
187
+ }
188
+ }
189
+
190
+ echo '</div>';
191
+
192
+ }
193
+ }
194
+ ?>
195
+
196
<table class="form-table">
197
<tbody>
198
<tr valign="top">
229
</tr> -->
230
231
<tr valign="top">
232
+ <th scope="row" style="padding-bottom: 10px;"><?php _e('Enter my Access Token', 'custom-facebook-feed'); ?><br /><i style="font-weight: normal; font-size: 12px; color: red;"><?php _e('Required', 'custom-facebook-feed'); ?></i></th>
233
<td>
234
<input name="cff_show_access_token" type="checkbox" id="cff_show_access_token" <?php if($show_access_token_val == true) echo "checked"; ?> />&nbsp;<a class="cff-tooltip-link" href="JavaScript:void(0);"><?php _e("What is this?", 'custom-facebook-feed'); ?></a>
235
+ <p class="cff-tooltip cff-more-info"><?php _e("In order to connect to Facebook and get a feed, you need to use an Access Token. To get one, simply use the blue button above to log into your Facebook account. You will then receive a token that will be used to connect to Facebook's API. If you already have an Access Token then you can enter it here.", 'custom-facebook-feed'); ?></p>
236
</td>
237
</tr>
238
239
<tr valign="top" class="cff-access-token-hidden">
240
<th scope="row" style="padding-bottom: 10px;"><?php _e('Facebook Access Token', 'custom-facebook-feed'); ?></th>
241
<td>
242
+ <textarea name="cff_access_token" id="cff_access_token" style="min-width: 60%;"><?php esc_attr_e( $access_token_val ); ?></textarea>
243
244
<div class="cff-notice cff-profile-error cff-access-token">
245
<?php _e("<p>This doesn't appear to be an Access Token. Please be sure that you didn't enter your App Secret instead of your Access Token.<br />Your App ID and App Secret are used to obtain your Access Token; simply paste them into the fields in the last step of the <a href='https://smashballoon.com/custom-facebook-feed/access-token/' target='_blank'>Access Token instructions</a> and click '<b>Get my Access Token</b>'.</p>", 'custom-facebook-feed'); ?>
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 completely customizable Facebook feeds to your WordPress site
6
- Version: 2.6.4
7
Author: Smash Balloon
8
Author URI: http://smashballoon.com/
9
License: GPLv2 or later
@@ -24,7 +24,7 @@ along with this program; if not, write to the Free Software
24
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
*/
26
27
- define('CFFVER', '2.6.4');
28
29
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
30
//Include admin
@@ -243,11 +243,6 @@ function display_cff($atts) {
243
if (!isset($cff_cache_time)) $cff_cache_time = '0';
244
$cff_cache_time_unit = $atts[ 'cacheunit' ];
245
246
- //Don't allow cache time to be less than 15 minutes in order to minimize API requests
247
- if(!isset($cff_cache_time) || $cff_cache_time == '0' || (intval($cff_cache_time) < 15 && $cff_cache_time_unit == 'minutes' ) ){
248
- $cff_cache_time = 15;
249
- $cff_cache_time_unit = 'minutes';
250
- }
251
if($cff_cache_time == 'nocaching') $cff_cache_time = 0;
252
253
$cff_class = $atts['class'];
@@ -711,7 +706,6 @@ function display_cff($atts) {
711
'294686830545691|3DhoPPXbNBmzlmXXK9cbLnGJTMI'
712
);
713
714
-
715
if ($access_token == '' || !$cff_show_access_token) $access_token = $access_token_array[rand(0, 33)];
716
717
//Check whether a Page ID has been defined
@@ -877,6 +871,8 @@ function display_cff($atts) {
877
//Limit var
878
$i_post = 0;
879
880
//Define array for post items
881
$cff_posts_array = array();
882
@@ -885,11 +881,17 @@ function display_cff($atts) {
885
886
$cff_posts_json_url = 'https://graph.facebook.com/' . $page_id . '/' . $graph_query . '?fields=id,from,message,message_tags,story,story_tags,link,source,name,caption,description,type,status_type,object_id,created_time&access_token=' . $access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale . $cff_ssl;
887
888
- //Temporarily set caching time to be minimum of 1 hour
889
- if( $cache_seconds < 3600 || !isset($cache_seconds) ) $cache_seconds = 3600;
890
891
- //Temporarily increase default caching time to be 4 hours
892
- if( $cache_seconds == 3600 ) $cache_seconds = 14400;
893
894
//Don't use caching if the cache time is set to zero
895
if ($cff_cache_time != 0){
@@ -912,7 +914,7 @@ function display_cff($atts) {
912
if( !empty($FBdata->data) ) {
913
914
//If it's a rate limit error then don't cache the response so another token can be used
915
- if (strpos($posts_json, '"error":{"message":"(#4) Application request limit reached",') == false) {
916
//Cache the JSON
917
set_transient( $transient_name, $posts_json, $cache_seconds );
918
}
3
Plugin Name: Custom Facebook Feed
4
Plugin URI: http://smashballoon.com/custom-facebook-feed
5
Description: Add completely customizable Facebook feeds to your WordPress site
6
+ Version: 2.7
7
Author: Smash Balloon
8
Author URI: http://smashballoon.com/
9
License: GPLv2 or later
24
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
*/
26
27
+ define('CFFVER', '2.7');
28
29
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
30
//Include admin
243
if (!isset($cff_cache_time)) $cff_cache_time = '0';
244
$cff_cache_time_unit = $atts[ 'cacheunit' ];
245
246
if($cff_cache_time == 'nocaching') $cff_cache_time = 0;
247
248
$cff_class = $atts['class'];
706
'294686830545691|3DhoPPXbNBmzlmXXK9cbLnGJTMI'
707
);
708
709
if ($access_token == '' || !$cff_show_access_token) $access_token = $access_token_array[rand(0, 33)];
710
711
//Check whether a Page ID has been defined
871
//Limit var
872
$i_post = 0;
873
874
+ if ($access_token == '' || !$cff_show_access_token) $access_token = '395202813876688|73e8ede72008b231a0322e40f0072fe6';
875
+
876
//Define array for post items
877
$cff_posts_array = array();
878
881
882
$cff_posts_json_url = 'https://graph.facebook.com/' . $page_id . '/' . $graph_query . '?fields=id,from,message,message_tags,story,story_tags,link,source,name,caption,description,type,status_type,object_id,created_time&access_token=' . $access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale . $cff_ssl;
883
884
885
+ if( $cff_show_access_token && strlen($access_token) > 130 ){
886
+ //If using a Page Access Token then set caching time to be minimum of 5 minutes
887
+ if( $cache_seconds < 300 || !isset($cache_seconds) ) $cache_seconds = 300;
888
+ } else {
889
+ //Temporarily set caching time to be minimum of 1 hour
890
+ if( $cache_seconds < 3600 || !isset($cache_seconds) ) $cache_seconds = 3600;
891
+
892
+ //Temporarily increase default caching time to be 4 hours
893
+ if( $cache_seconds == 3600 ) $cache_seconds = 14400;
894
+ }
895
896
//Don't use caching if the cache time is set to zero
897
if ($cff_cache_time != 0){
914
if( !empty($FBdata->data) ) {
915
916
//If it's a rate limit error then don't cache the response so another token can be used
917
+ if (strpos($posts_json, '"error":{"message":"(#4) Application request limit reached",') == false && strpos($posts_json, 'Error validating application. Application has been deleted.') == false) {
918
//Cache the JSON
919
set_transient( $transient_name, $posts_json, $cache_seconds );
920
}
img/slick-remix.png ADDED
Binary file
js/cff-admin-scripts.js CHANGED
@@ -187,4 +187,25 @@ jQuery(document).ready(function($) {
187
}
188
});
189
190
});
187
}
188
});
189
190
+ //Facebook login
191
+ $('#cff_fb_login').on('click', function(){
192
+ $('#cff_fb_login_modal').show();
193
+ });
194
+ $('#cff_admin_cancel_btn').on('click', function(){
195
+ $('#cff_fb_login_modal').hide();
196
+ });
197
+
198
+ //Select a page for token
199
+ $('.cff-managed-page').on('click', function(){
200
+ $('#cff_access_token, #cff_page_access_token').val( $(this).attr('data-token') ).addClass('cff-success');
201
+ // $('#cff_page_id').val( $(this).attr('data-page-id') );
202
+ $(this).siblings().removeClass('cff-page-selected');
203
+ $(this).addClass('cff-page-selected');
204
+ // $('.cff-save-page-token').show();
205
+ //Check the own access token setting so it reveals token field
206
+ if( $('#cff_show_access_token:checked').length < 1 ){
207
+ $("#cff_show_access_token").trigger("change").prop( "checked", true );
208
+ }
209
+ });
210
+
211
});