Custom Facebook Feed - Version 2.6.3

Version Description

  • Fix: Fixed an issue where API errors were being cached
Download this release

Release Info

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

Code changes from version 2.6.2 to 2.6.3

Files changed (2) hide show
  1. README.txt +4 -1
  2. custom-facebook-feed.php +41 -30
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.2
7
License: GPLv2 or later
8
License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
@@ -265,6 +265,9 @@ You no longer need your own Access Token to use the Custom Facebook Feed Plugin,
265
266
== Changelog ==
267
268
= 2.6.2 =
269
* Fix: Replaced all HTTP links with HTTPS
270
* Fix: Fixed a rare issue which affected the layout of other Facebook widgets
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.3
7
License: GPLv2 or later
8
License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
265
266
== Changelog ==
267
268
+ = 2.6.3 =
269
+ * Fix: Fixed an issue where API errors were being cached
270
+
271
= 2.6.2 =
272
* Fix: Replaced all HTTP links with HTTPS
273
* Fix: Fixed a rare issue which affected the layout of other Facebook widgets
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.2
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.2');
28
29
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
30
//Include admin
@@ -248,7 +248,7 @@ function display_cff($atts) {
248
$cff_cache_time = 15;
249
$cff_cache_time_unit = 'minutes';
250
}
251
- if($cff_cache_time == 'none') $cff_cache_time = 0;
252
253
$cff_class = $atts['class'];
254
//Compile feed styles
@@ -677,36 +677,42 @@ function display_cff($atts) {
677
$access_token_array = array(
678
'1786066011417150|5043eac44ee54731ed404b9db021cdf2',
679
'1795317140689602|e25d547c4f12164254f85eead086b0a7',
680
- '181607922248075|d0787a2cfff89efd23b9fe1ffafa45db',
681
'1851314935096786|0de2a9ec77d745d6941850696ce166f9',
682
- '1983264355330375|e5c100f6d4b768abb560e7df1771ac89',
683
- '209804229584368|3a2d59f876e0df3d42d829f8a1569636',
684
- '274376249625432|03d7cc70158f4b720a124c11aad5606e',
685
- '927474184059774|ekzzwIV9JnvG-ELYWut9wIvf4Y0',
686
- '157849737751172|1wgUYn-UwVvoiZkvROi7yi2aIRw',
687
- '140081703552|rtuoT3AGRIzb-z_PPUlOnN9iYA0',
688
'322095208287051|pbCTS6jPuhjR18sl2UPhKQw7eyY',
689
- '1439406912938596|4JDCXisJ2d-1EWeObBt27DybH5c',
690
'1042396375891598|gn2HiZgDgjTbCMcXsSb6VK91PqM',
691
'348613608818294|d4gRX7tNppCrI-DrOGof_O8gwvg',
692
- '502797619766223|fuoqcs_7_9HPokY0C296S4VtB0o',
693
'1591407604237466|cHUFs9XDDJa7LDUW9zBxirwGAHE',
694
- '277269689412168|o3k5mzmHsT-prqc2qizxk_DoXEQ',
695
- '386881278380301|NW_PiECD9TLVe0UNMsB5H9HkPEo',
696
'697312047120344|p8ST5dkrub6IoBZsClmyRBTScB0',
697
'1134584793234186|763Jh88I-PuO8_slARazfgucxFg',
698
- '257106408010811|MwCorr7qsyIeU_GjdPFIEw3-_P8',
699
- '1693018934313805|VYDjx69NpsgkDEAm79cYD0fxJBk',
700
- '1298990730176646|rU4QhoOaYPWQng6-k_QdxRoVNaA',
701
'1788677371359317|UU7yeB5dsKOT8xLsLA9xSNu4OMQ',
702
- '1876405409266356|VT8hdBxkbAf6-PCq-TosrtiMilU',
703
- '128947497630881|rlgLr8wtMUWRw7hbcLcsgoa01-k',
704
- '963645750343660|1mgCt1EhXAI0o51tYpZ7O6dThKM',
705
- '177899259380474|JgdlhmU-J0dq55bKng0xywDIgIo',
706
- '1106367462776766|Pj4xBlwzMH53yCQw7-h_prMExQg',
707
- '131153380694449|jxU6_J0SobvxNG-pzJW8MKsI0w8'
708
);
709
- if ($access_token == '' || !$cff_show_access_token) $access_token = $access_token_array[rand(0, 29)];
710
711
//Check whether a Page ID has been defined
712
if ($page_id == '') {
@@ -879,11 +885,11 @@ function display_cff($atts) {
879
880
$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;
881
882
- //Temporarily set caching time to be minimum of 30 minutes
883
- if( $cache_seconds < 1800 || !isset($cache_seconds) ) $cache_seconds = 1800;
884
885
- //Temporarily increase default caching time to be 2 hours
886
- if( $cache_seconds == 3600 ) $cache_seconds = 7200;
887
888
//Don't use caching if the cache time is set to zero
889
if ($cff_cache_time != 0){
@@ -904,8 +910,13 @@ function display_cff($atts) {
904
//Check whether any data is returned from the API. If it isn't then don't cache the error response and instead keep checking the API on every page load until data is returned.
905
$FBdata = json_decode($posts_json);
906
if( !empty($FBdata->data) ) {
907
- //Cache the JSON
908
- set_transient( $transient_name, $posts_json, $cache_seconds );
909
}
910
} else {
911
$posts_json = get_transient( $transient_name );
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.3
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.6.3');
28
29
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
30
//Include admin
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'];
254
//Compile feed styles
677
$access_token_array = array(
678
'1786066011417150|5043eac44ee54731ed404b9db021cdf2',
679
'1795317140689602|e25d547c4f12164254f85eead086b0a7',
680
'1851314935096786|0de2a9ec77d745d6941850696ce166f9',
681
'322095208287051|pbCTS6jPuhjR18sl2UPhKQw7eyY',
682
'1042396375891598|gn2HiZgDgjTbCMcXsSb6VK91PqM',
683
'348613608818294|d4gRX7tNppCrI-DrOGof_O8gwvg',
684
'1591407604237466|cHUFs9XDDJa7LDUW9zBxirwGAHE',
685
'697312047120344|p8ST5dkrub6IoBZsClmyRBTScB0',
686
'1134584793234186|763Jh88I-PuO8_slARazfgucxFg',
687
'1788677371359317|UU7yeB5dsKOT8xLsLA9xSNu4OMQ',
688
+ '1024245627652108|VmyBFUaBhjmvF31kPWdLcwtA0nU',
689
+ '1665626540320930|kDmIPfF8Y0mvV5mPr3927c2nRlM',
690
+ '219254908466738|9AAaE_5GnONhVWUTlEBS8LDiFi8',
691
+ '383334425112756|cxkb0YngoQPVkr7AngA_LOE2TV8',
692
+ '1711513059125773|IuTAeRQAzhUelndJ_n7jPx3yOxs',
693
+ '1425047524403499|shKbcYtt0KmDzOG5n9hkuVmP1bA',
694
+ '1677248395890039|CSZsE5C-HJ8cYOraU6J6gwACZys',
695
+ '162288250832230|HvQ8grGeT3QGVEFgRkooK-V55vs',
696
+ '258557634485082|vBEtyzuLUrCVDeks57FPNbH5YCo',
697
+ '1028332560591295|InX-Kx2LF2tjcfjbz4ddP6wXJ6U',
698
+ '1816228771930249|xW0dj0nD-gWTl9oUEFyz7kCn4Gk',
699
+ '451848331655448|YnHljWJNCMRxlo5JwAQRukxqQj0',
700
+ '1590285041189842|PNrjtuwPpJWAda9GjvDnYCZvQH0',
701
+ '1425919427736604|6NKiBWf5_rR4DuV2z1E_Pk27F2I',
702
+ '198080700214649|natEgdD5R82UoiLXL5UsUK82-O8',
703
+ '452046251639377|sruLhZT7bktRpuPy0txclkvCMWE',
704
+ '282581258595802|QRueniLvr6ppOBW9UcNpJVswGKw',
705
+ '120755681588984|8IamCzI5D56psRs_726PwSgUgos',
706
+ '236542103198412|YZBFLCWsx_ap_c2rmznf_tEbh6E',
707
+ '820682411352870|0W2O9df8U0suAfllTVdPP2Zl8lI',
708
+ '444110102425340|1xyyWHpqzWy5jNrMnNAsMgIIKVI',
709
+ '334097170130531|fpcajp_H4f79HoAP2j5Ryo_0OKE',
710
+ '350665888465252|pi9du5kAZ9JRDAfxzNpq-S7w7Zw',
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
718
if ($page_id == '') {
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){
910
//Check whether any data is returned from the API. If it isn't then don't cache the error response and instead keep checking the API on every page load until data is returned.
911
$FBdata = json_decode($posts_json);
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
+ }
919
+
920
}
921
} else {
922
$posts_json = get_transient( $transient_name );