Custom Facebook Feed - Version 4.1.5

Version Description

  • Fix: An error message will now display if there was a problem connecting an account.
  • Fix: The Post Date could not be disabled.
Download this release

Release Info

Developer Craig at Smash Balloon
Plugin Icon 128x128 Custom Facebook Feed
Version 4.1.5
Comparing to
See all releases

Code changes from version 4.1.4 to 4.1.5

README.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Smash Balloon Social Post Feed ===
2
- Contributors: smashballoon
3
  Tags: Facebook, Facebook feed, Facebook posts, Facebook group, Facebook page
4
  Requires at least: 4.1
5
  Requires PHP: 5.6
6
- Tested up to: 6.0
7
- Stable tag: 4.1.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -262,6 +262,10 @@ The most common reason for this is that an add-on or extension you have installe
262
  9. It's super easy to display your Facebook feed in any page or post
263
 
264
  == Changelog ==
 
 
 
 
265
  = 4.1.4 =
266
  * Tweak: Updated compatibility with the upcoming WordPress 6.0 release.
267
  * Tweak: Made improvements to how notices are displayed on our plugin settings pages.
1
  === Smash Balloon Social Post Feed ===
2
+ Contributors: smashballoon, craig-at-smash-balloon, am, smub
3
  Tags: Facebook, Facebook feed, Facebook posts, Facebook group, Facebook page
4
  Requires at least: 4.1
5
  Requires PHP: 5.6
6
+ Tested up to: 6.1
7
+ Stable tag: 4.1.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
262
  9. It's super easy to display your Facebook feed in any page or post
263
 
264
  == Changelog ==
265
+ = 4.1.5 =
266
+ * Fix: An error message will now display if there was a problem connecting an account.
267
+ * Fix: The Post Date could not be disabled.
268
+
269
  = 4.1.4 =
270
  * Tweak: Updated compatibility with the upcoming WordPress 6.0 release.
271
  * Tweak: Made improvements to how notices are displayed on our plugin settings pages.
admin/builder/assets/js/add-source.js CHANGED
@@ -208,9 +208,13 @@ Vue.component('sb-add-source-component', {
208
  'sourcesList' : sourcesListToAdd
209
  };
210
  self.$parent.ajaxPost(connectSourceData, function(_ref){
211
- var data = _ref.data;
212
- self.sourcesList = data;
213
- self.$parent.sourcesList = data;
 
 
 
 
214
  self.$parent.viewsActive.sourcePopup = false;
215
  if(self.$parent.customizerFeedData){
216
  self.$parent.activateView('sourcePopup', 'customizer');
208
  'sourcesList' : sourcesListToAdd
209
  };
210
  self.$parent.ajaxPost(connectSourceData, function(_ref){
211
+ var data = _ref.data,
212
+ sourcesList = data.sourcesList;
213
+ if( data?.hasError ){
214
+ self.$parent.processNotification("addSourceError");
215
+ }
216
+ self.sourcesList = sourcesList;
217
+ self.$parent.sourcesList = sourcesList;
218
  self.$parent.viewsActive.sourcePopup = false;
219
  if(self.$parent.customizerFeedData){
220
  self.$parent.activateView('sourcePopup', 'customizer');
custom-facebook-feed.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Smash Balloon Custom Facebook Feed
4
  Plugin URI: https://smashballoon.com/custom-facebook-feed
5
  Description: Add completely customizable Facebook feeds to your WordPress site
6
- Version: 4.1.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
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
27
- define('CFFVER', '4.1.4');
28
  define( 'WPW_SL_STORE_URL', 'https://smashballoon.com/' );
29
  define( 'WPW_SL_ITEM_NAME', 'Custom Facebook Feed WordPress Plugin Personal' ); //*!*Update Plugin Name at top of file*!*
30
 
3
  Plugin Name: Smash Balloon Custom Facebook Feed
4
  Plugin URI: https://smashballoon.com/custom-facebook-feed
5
  Description: Add completely customizable Facebook feeds to your WordPress site
6
+ Version: 4.1.5
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
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
27
+ define('CFFVER', '4.1.5');
28
  define( 'WPW_SL_STORE_URL', 'https://smashballoon.com/' );
29
  define( 'WPW_SL_ITEM_NAME', 'Custom Facebook Feed WordPress Plugin Personal' ); //*!*Update Plugin Name at top of file*!*
30
 
inc/Builder/CFF_Db.php CHANGED
@@ -7,6 +7,7 @@
7
 
8
  namespace CustomFacebookFeed\Builder;
9
  use CustomFacebookFeed\SB_Facebook_Data_Encryption;
 
10
 
11
  class CFF_Db {
12
 
@@ -27,6 +28,7 @@ class CFF_Db {
27
  global $wpdb;
28
  $sources_table_name = $wpdb->prefix . 'cff_sources';
29
  $feeds_table_name = $wpdb->prefix . 'cff_feeds';
 
30
 
31
  $page = 0;
32
  if ( isset( $args['page'] ) ) {
@@ -67,6 +69,10 @@ class CFF_Db {
67
  $results[ $i ]['instances'] = $wpdb->get_results( $sql, ARRAY_A );
68
  }
69
  $i++;
 
 
 
 
70
  }
71
 
72
 
7
 
8
  namespace CustomFacebookFeed\Builder;
9
  use CustomFacebookFeed\SB_Facebook_Data_Encryption;
10
+ use CustomFacebookFeed\CFF_Utils;
11
 
12
  class CFF_Db {
13
 
28
  global $wpdb;
29
  $sources_table_name = $wpdb->prefix . 'cff_sources';
30
  $feeds_table_name = $wpdb->prefix . 'cff_feeds';
31
+ $encryption = new SB_Facebook_Data_Encryption();
32
 
33
  $page = 0;
34
  if ( isset( $args['page'] ) ) {
69
  $results[ $i ]['instances'] = $wpdb->get_results( $sql, ARRAY_A );
70
  }
71
  $i++;
72
+ if ( isset( $result['access_token'] ) && strpos( $result['access_token'], 'IG' ) === false && strpos( $result['access_token'], 'EA' ) === false && ! $encryption->decrypt( $result['access_token'] ) ) {
73
+ //Add the Error for global notifications
74
+ CFF_Source::add_report_error_option($result);
75
+ }
76
  }
77
 
78
 
inc/Builder/CFF_Feed_Builder.php CHANGED
@@ -1045,6 +1045,10 @@ class CFF_Feed_Builder {
1045
  'type' => 'error',
1046
  'text' => __( 'Please select a source for your feed', 'custom-facebook-feed' )
1047
  ),
 
 
 
 
1048
  ),
1049
  'install' => __( 'Install', 'custom-facebook-feed' ),
1050
  'installed' => __( 'Installed', 'custom-facebook-feed' ),
1045
  'type' => 'error',
1046
  'text' => __( 'Please select a source for your feed', 'custom-facebook-feed' )
1047
  ),
1048
+ 'addSourceError' => array(
1049
+ 'type' => 'error',
1050
+ 'text' => __( 'Couldn\'t connect one or more sources!', 'custom-facebook-feed' )
1051
+ ),
1052
  ),
1053
  'install' => __( 'Install', 'custom-facebook-feed' ),
1054
  'installed' => __( 'Installed', 'custom-facebook-feed' ),
inc/Builder/CFF_Source.php CHANGED
@@ -6,6 +6,8 @@
6
  */
7
 
8
  namespace CustomFacebookFeed\Builder;
 
 
9
 
10
  class CFF_Source {
11
 
@@ -135,7 +137,7 @@ class CFF_Source {
135
  if ( ! current_user_can( $cap ) ) {
136
  wp_send_json_error(); // This auto-dies.
137
  }
138
-
139
  if(isset($_POST['sourcesList']) && !empty($_POST['sourcesList']) && is_array($_POST['sourcesList'])){
140
  foreach ($_POST['sourcesList'] as $single_source):
141
  $source_data = array(
@@ -158,10 +160,18 @@ class CFF_Source {
158
  $source_data['error'] = '';
159
  $source_data['info']->connected_version = CFFVER;
160
  CFF_Source::update_or_insert( $source_data );
 
 
161
  }
162
  endforeach;
163
  }
164
- echo \CustomFacebookFeed\CFF_Utils::cff_json_encode( CFF_Feed_Builder::get_source_list() );
 
 
 
 
 
 
165
  }
166
 
167
  wp_die();
@@ -1055,4 +1065,25 @@ class CFF_Source {
1055
  );
1056
  return \CustomFacebookFeed\Builder\CFF_Source::update_or_insert( $source_data );
1057
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1058
  }
6
  */
7
 
8
  namespace CustomFacebookFeed\Builder;
9
+ use CustomFacebookFeed\CFF_Response;
10
+ use CustomFacebookFeed\CFF_Utils;
11
 
12
  class CFF_Source {
13
 
137
  if ( ! current_user_can( $cap ) ) {
138
  wp_send_json_error(); // This auto-dies.
139
  }
140
+ $has_error = false;
141
  if(isset($_POST['sourcesList']) && !empty($_POST['sourcesList']) && is_array($_POST['sourcesList'])){
142
  foreach ($_POST['sourcesList'] as $single_source):
143
  $source_data = array(
160
  $source_data['error'] = '';
161
  $source_data['info']->connected_version = CFFVER;
162
  CFF_Source::update_or_insert( $source_data );
163
+ }else{
164
+ $has_error = true;
165
  }
166
  endforeach;
167
  }
168
+ $response = [
169
+ 'sourcesList' => CFF_Feed_Builder::get_source_list()
170
+ ];
171
+ if( $has_error ){
172
+ $response['hasError'] = true;
173
+ }
174
+ echo \CustomFacebookFeed\CFF_Utils::cff_json_encode( $response );
175
  }
176
 
177
  wp_die();
1065
  );
1066
  return \CustomFacebookFeed\Builder\CFF_Source::update_or_insert( $source_data );
1067
  }
1068
+
1069
+
1070
+ /**
1071
+ * Add error to the option table "cff_error_reporter"
1072
+ *
1073
+ * @param string $account_id
1074
+ * @param string|object|array $error
1075
+ *
1076
+ * @return bool
1077
+ *
1078
+ * @since 4.0.3
1079
+ */
1080
+ public static function add_report_error_option( $account) {
1081
+ $errors = get_option( 'cff_error_reporter', [] );
1082
+ $add_error = (isset( $errors['connection'] ) && isset( $errors['connection']['error_id'] ) && $errors['connection']['error_id'] == 190) ? false : true;
1083
+ if( $add_error ){
1084
+ $url = 'https://graph.facebook.com/v4.0/'.$account['account_id'].'/posts?fields=id,updated_time,from{picture,id,name,link},message,message_tags,story,story_tags,status_type,created_time,backdated_time,call_to_action,attachments{title,description,media_type,unshimmed_url,target{id},media{source}}&access_token='. $account['access_token'].'&limit=7&locale=en_US';
1085
+ CFF_Utils::cff_fetchUrl($url, false);
1086
+ }
1087
+
1088
+ }
1089
  }
inc/CFF_Utils.php CHANGED
@@ -20,9 +20,8 @@ class CFF_Utils{
20
  * @static
21
  * @since 2.19
22
  */
23
- static function cff_fetchUrl($url){
24
  $response = wp_remote_get( $url );
25
-
26
  if ( ! CFF_Utils::cff_is_wp_error( $response ) ) {
27
  $feedData = wp_remote_retrieve_body( $response );
28
 
@@ -36,9 +35,10 @@ class CFF_Utils{
36
  return $feedData;
37
  } else {
38
  if ( strpos( $url, '&limit=' ) !== false ) {
39
- CFF_Utils::cff_log_fb_error( $feedData, $url );
40
  }
41
 
 
42
  $error = json_decode( $feedData, true );
43
  $reporter = CFF_Utils::cff_is_pro_version() ? \cff_main_pro()->cff_error_reporter : \cff_main()->cff_error_reporter;
44
 
@@ -181,11 +181,10 @@ class CFF_Utils{
181
  * @static
182
  * @since 2.19
183
  */
184
- static function cff_log_fb_error( $response, $url ) {
185
- if ( is_admin() ) {
186
  return;
187
  }
188
-
189
  delete_option( 'cff_dismiss_critical_notice' );
190
 
191
  $access_token_refresh_errors = array( 10, 4, 200 );
20
  * @static
21
  * @since 2.19
22
  */
23
+ static function cff_fetchUrl( $url, $check_admin = true){
24
  $response = wp_remote_get( $url );
 
25
  if ( ! CFF_Utils::cff_is_wp_error( $response ) ) {
26
  $feedData = wp_remote_retrieve_body( $response );
27
 
35
  return $feedData;
36
  } else {
37
  if ( strpos( $url, '&limit=' ) !== false ) {
38
+ CFF_Utils::cff_log_fb_error( $feedData, $url, $check_admin );
39
  }
40
 
41
+
42
  $error = json_decode( $feedData, true );
43
  $reporter = CFF_Utils::cff_is_pro_version() ? \cff_main_pro()->cff_error_reporter : \cff_main()->cff_error_reporter;
44
 
181
  * @static
182
  * @since 2.19
183
  */
184
+ static function cff_log_fb_error( $response, $url, $check_admin = true ) {
185
+ if ( is_admin() && $check_admin == true ) {
186
  return;
187
  }
 
188
  delete_option( 'cff_dismiss_critical_notice' );
189
 
190
  $access_token_refresh_errors = array( 10, 4, 200 );
templates/item/container.php CHANGED
@@ -21,8 +21,10 @@ $post_item_attr = $this_class->get_item_attributes($cff_post_type, $cff_album, $
21
  echo $cff_post_text;
22
  if( $cff_show_shared_links )
23
  echo $cff_shared_link;
 
24
  if ( (!$cff_show_author && $cff_date_position == 'author') || $cff_show_date && $cff_date_position == 'below' )
25
  echo $cff_date;
 
26
  if( $cff_show_media_link )
27
  echo $cff_media_link;
28
  if( $cff_show_link )
21
  echo $cff_post_text;
22
  if( $cff_show_shared_links )
23
  echo $cff_shared_link;
24
+ /*
25
  if ( (!$cff_show_author && $cff_date_position == 'author') || $cff_show_date && $cff_date_position == 'below' )
26
  echo $cff_date;
27
+ */
28
  if( $cff_show_media_link )
29
  echo $cff_media_link;
30
  if( $cff_show_link )