Custom Facebook Feed - Version 2.19.1

Version Description

  • New: In this update, the plugin will now use a persistent cache to store your Facebook group posts. This will help minimize any affects of a Facebook API change on May 25th which will only allow Facebook Groups to retrieve content from the past 90 days. The plugin will store your group posts in the persistent cache so that those posts can continue to be displayed beyond 90 days. This update will also make a one-time request to get the last 100 posts from your group and store those too, so that the affect of this change will be minimal for our users. Please see here for more information.
  • Tweak: Updated jQuery methods in preparation for jQuery migrate removal in an upcoming WordPress core update.
  • Tweak: Added option to enqueue CSS and JS files only when shortcode is on the page.
  • Tweak: Added an reset error log button to the settings page.
  • Tweak: Added an option to hide the call-to-action button in the post content.
  • Fix: Changed how access tokens are retrieved to prevent conflict with the "Rank Math SEO" plugin when connecting an account.
  • Fix: Fixed an error in the Feed Finder tool when removing accounts.
  • Fix: Fixed an issue with duplicated records in the feed finder.
  • Fix: Fixed "Unknown error" response with API story tag calls.
Download this release

Release Info

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

Code changes from version 2.19 to 2.19.1

README.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: smashballoon
3
  Tags: Facebook, Facebook feed, Facebook posts, Facebook group, Facebook page
4
  Requires at least: 3.0
5
  Requires PHP: 5.6
6
- Tested up to: 5.6
7
- Stable tag: 2.19
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -262,12 +262,22 @@ 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
  = 2.19 =
266
  * New: Improved the error reporting system to make resolving issues easier.
267
  * New: The locations of the Facebook feeds on your site will now be logged and listed on a single page for easier management. After this feature has been active for awhile, a "Feed Finder" link will appear under your connected accounts on the plugin Settings page which allows you to see a list of all feeds on your site along with their locations.
268
  * Tweak: When clearing the plugin cache, the cache in the Litespeed plugin will now also be cleared if being used on the site.
269
  * Fix: Fixed an issue with anonymous avatars not displaying correctly in group feeds.
270
- * Fix: Added a fix for apostrophes in connected accounts.
271
 
272
  = 2.18.3 =
273
  * Tweak: Updated deprecated jQuery functions to prevent potential issues with newer versions.
3
  Tags: Facebook, Facebook feed, Facebook posts, Facebook group, Facebook page
4
  Requires at least: 3.0
5
  Requires PHP: 5.6
6
+ Tested up to: 5.7
7
+ Stable tag: 2.19.1
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
+ = 2.19.1 =
266
+ * New: In this update, the plugin will now use a persistent cache to store your Facebook group posts. This will help minimize any affects of a Facebook API change on May 25th which will only allow Facebook Groups to retrieve content from the past 90 days. The plugin will store your group posts in the persistent cache so that those posts can continue to be displayed beyond 90 days. This update will also make a one-time request to get the last 100 posts from your group and store those too, so that the affect of this change will be minimal for our users. Please [see here](https://smashballoon.com/doc/facebook-api-change-limits-groups-to-90-days/) for more information.
267
+ * Tweak: Updated jQuery methods in preparation for jQuery migrate removal in an upcoming WordPress core update.
268
+ * Tweak: Added option to enqueue CSS and JS files only when shortcode is on the page.
269
+ * Tweak: Added an reset error log button to the settings page.
270
+ * Tweak: Added an option to hide the call-to-action button in the post content.
271
+ * Fix: Changed how access tokens are retrieved to prevent conflict with the "Rank Math SEO" plugin when connecting an account.
272
+ * Fix: Fixed an error in the Feed Finder tool when removing accounts.
273
+ * Fix: Fixed an issue with duplicated records in the feed finder.
274
+ * Fix: Fixed "Unknown error" response with API story tag calls.
275
+
276
  = 2.19 =
277
  * New: Improved the error reporting system to make resolving issues easier.
278
  * New: The locations of the Facebook feeds on your site will now be logged and listed on a single page for easier management. After this feature has been active for awhile, a "Feed Finder" link will appear under your connected accounts on the plugin Settings page which allows you to see a list of all feeds on your site along with their locations.
279
  * Tweak: When clearing the plugin cache, the cache in the Litespeed plugin will now also be cleared if being used on the site.
280
  * Fix: Fixed an issue with anonymous avatars not displaying correctly in group feeds.
 
281
 
282
  = 2.18.3 =
283
  * Tweak: Updated deprecated jQuery functions to prevent potential issues with newer versions.
admin/admin-functions.php CHANGED
@@ -4,6 +4,12 @@ use CustomFacebookFeed\CFF_Oembed;
4
  use CustomFacebookFeed\CFF_GDPR_Integrations;
5
  use CustomFacebookFeed\CFF_Feed_Locator;
6
 
 
 
 
 
 
 
7
  //Create Style page
8
  function cff_style_page() {
9
  //Declare variables for fields
@@ -143,6 +149,7 @@ use CustomFacebookFeed\CFF_Feed_Locator;
143
  'cff_app_id' => '',
144
  'cff_show_credit' => '',
145
  'cff_font_source' => '',
 
146
  'cff_minify' => false,
147
  'disable_admin_notice' => false,
148
  'cff_sep_color' => '',
@@ -364,6 +371,7 @@ use CustomFacebookFeed\CFF_Feed_Locator;
364
  $cff_disable_styles = $options[ 'cff_disable_styles' ];
365
  $cff_format_issue = $options[ 'cff_format_issue' ];
366
  $cff_restricted_page = $options[ 'cff_restricted_page' ];
 
367
  $cff_minify = $options[ 'cff_minify' ];
368
  $cff_cols = $options[ 'cff_cols' ];
369
  $cff_cols_mobile = $options[ 'cff_cols_mobile' ];
@@ -417,7 +425,6 @@ use CustomFacebookFeed\CFF_Feed_Locator;
417
  $cff_ajax = 'cff_ajax';
418
  $cff_ajax_val = get_option( $cff_ajax );
419
 
420
-
421
  //Check nonce before saving data
422
  if ( ! isset( $_POST['cff_customize_nonce'] ) || ! wp_verify_nonce( $_POST['cff_customize_nonce'], 'cff_saving_customize' ) ) {
423
  //Nonce did not verify
@@ -787,6 +794,7 @@ use CustomFacebookFeed\CFF_Feed_Locator;
787
  (isset($_POST[ 'cff_disable_styles' ])) ? $cff_disable_styles = sanitize_text_field( $_POST[ 'cff_disable_styles' ] ) : $cff_disable_styles = '';
788
  (isset($_POST[ 'cff_format_issue' ])) ? $cff_format_issue = sanitize_text_field( $_POST[ 'cff_format_issue' ] ) : $cff_format_issue = '';
789
  (isset($_POST[ 'cff_restricted_page' ])) ? $cff_restricted_page = sanitize_text_field( $_POST[ 'cff_restricted_page' ] ) : $cff_restricted_page = '';
 
790
  (isset($_POST[ 'cff_minify' ])) ? $cff_minify = sanitize_text_field( $_POST[ 'cff_minify' ] ) : $cff_minify = '';
791
  (isset($_POST[ 'cff_disable_admin_notice' ])) ? $cff_disable_admin_notice = sanitize_text_field( $_POST[ 'cff_disable_admin_notice' ] ) : $cff_disable_admin_notice = '';
792
 
@@ -810,6 +818,7 @@ use CustomFacebookFeed\CFF_Feed_Locator;
810
  $options[ 'cff_disable_styles' ] = $cff_disable_styles;
811
  $options[ 'cff_format_issue' ] = $cff_format_issue;
812
  $options[ 'cff_restricted_page' ] = $cff_restricted_page;
 
813
  $options[ 'cff_minify' ] = $cff_minify;
814
  $options[ 'disable_admin_notice' ] = $cff_disable_admin_notice;
815
 
@@ -819,15 +828,13 @@ use CustomFacebookFeed\CFF_Feed_Locator;
819
  if( $cff_cron == 'yes' ){
820
  //Clear the existing cron event
821
  wp_clear_scheduled_hook('cff_cron_job');
822
-
823
  $cff_cache_time = get_option( 'cff_cache_time' );
824
- $cff_cache_time_unit = get_option( 'cff_cache_time_unit' );
825
-
826
- //Set the event schedule based on what the caching time is set to
827
- $cff_cron_schedule = 'hourly';
828
- if( $cff_cache_time_unit == 'hours' && $cff_cache_time > 5 ) $cff_cron_schedule = 'twicedaily';
829
- if( $cff_cache_time_unit == 'days' ) $cff_cron_schedule = 'daily';
830
 
 
 
 
 
831
  wp_schedule_event(time(), $cff_cron_schedule, 'cff_cron_job');
832
  }
833
 
@@ -3033,6 +3040,15 @@ use CustomFacebookFeed\CFF_Feed_Locator;
3033
  </td>
3034
  </tr>
3035
 
 
 
 
 
 
 
 
 
 
3036
  <tr>
3037
  <th class="bump-left"><label class="bump-left"><?php _e("Minify CSS and JavaScript files"); ?></label></th>
3038
  <td>
@@ -3416,6 +3432,7 @@ function cff_settings_page() {
3416
  if ( ! isset( $_POST['cff_settings_nonce'] ) || ! wp_verify_nonce( $_POST['cff_settings_nonce'], 'cff_saving_settings' ) ) {
3417
  //Nonce did not verify
3418
  } else {
 
3419
  // See if the user has posted us some information. If they did, this hidden field will be set to 'Y'.
3420
  if( isset($_POST[ $hidden_field_name ]) && $_POST[ $hidden_field_name ] == 'Y' ) {
3421
  // Read their posted value
@@ -3450,6 +3467,10 @@ function cff_settings_page() {
3450
  $options[ 'cff_timezone' ] = $cff_timezone;
3451
  $options[ 'cff_num_mobile' ] = $cff_num_mobile;
3452
  update_option( 'cff_style_settings', $options );
 
 
 
 
3453
 
3454
  //Delete ALL transients
3455
  cff_delete_cache();
@@ -3528,9 +3549,9 @@ function cff_settings_page() {
3528
  $admin_url_state = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
3529
  }
3530
  ?>
3531
- <a href="https://api.smashballoon.com/facebook-login.php?state=<?php echo $admin_url_state; ?>" class="cff_admin_btn" id="cff_page_app"><i class="fa fa-facebook-square"></i> <?php _e( 'Continue', 'custom-facebook-feed' ); ?></a>
3532
 
3533
- <a href="https://api.smashballoon.com/facebook-group-login.php?state=<?php echo $admin_url_state; ?>" class="cff_admin_btn" id="cff_group_app"><i class="fa fa-facebook-square"></i> <?php _e( 'Continue', 'custom-facebook-feed' ); ?></a>
3534
 
3535
  </p>
3536
  </div>
@@ -3544,20 +3565,19 @@ function cff_settings_page() {
3544
 
3545
 
3546
  <?php
3547
- if( isset($_GET['access_token']) && isset($_GET['final_response']) ){
3548
-
3549
- if( $_GET['final_response'] == 'true' ){
3550
 
 
3551
 
3552
  \cff_main()->cff_error_reporter->remove_error( 'connection' );
3553
  \cff_main()->cff_error_reporter->add_action_log( 'Connection or updating account');
3554
 
3555
- $access_token = $_GET['access_token'];
3556
  $cff_is_groups = false;
3557
  $pages_data_arr = '';
3558
  $groups_data_arr = '';
3559
 
3560
- if( isset($_GET['group']) ){
3561
  //Get Groups
3562
 
3563
  $cff_is_groups = true;
@@ -3761,9 +3781,9 @@ function cff_settings_page() {
3761
  <?php
3762
  //When connecting an account check the current access token to see if it has an error. If so then add a class to the field and replace it automatically in JS when getting a new one.
3763
  $cff_replace_token = false;
3764
- if( isset($_GET['access_token']) && isset($_GET['final_response']) ){
3765
 
3766
- if( $_GET['final_response'] == 'true' ){
3767
  $api_page_id = trim($page_id_val);
3768
  $url = 'https://graph.facebook.com/'.$api_page_id.'?limit=1&fields=id&access_token='.$access_token_val;
3769
  $accounts_data = CFF_Utils::cff_fetchUrl($url);
@@ -4571,6 +4591,7 @@ foreach( $oembed_token_settings as $key => $value ) {
4571
 
4572
  ?>
4573
  </textarea>
 
4574
 
4575
  <?php } //End support tab
4576
 
@@ -4895,7 +4916,7 @@ function cff_oembeds_page() {
4895
  $access_token_error = false;
4896
  $valid_new_access_token = false;
4897
  $show_token_expiration_modal = false;
4898
- if ( ! empty( $_GET['access_token'] ) && strlen( $_GET['access_token'] ) <= 20 ) {
4899
  $access_token_error = true;
4900
  } elseif ( ! empty( $_GET['transfer'] ) ) {
4901
  if ( class_exists( 'SB_Instagram_Oembed' ) ) {
@@ -4903,8 +4924,8 @@ function cff_oembeds_page() {
4903
  $valid_new_access_token = $sbi_oembed_token;
4904
  }
4905
  } else {
4906
- $valid_new_access_token = ! empty( $_GET['access_token'] ) && strlen( $_GET['access_token'] ) > 20 && $saved_access_token_data !== $_GET['access_token'] ? sanitize_text_field( $_GET['access_token'] ) : false;
4907
- if ( $valid_new_access_token && ! empty( $_GET['access_token'] ) ) {
4908
  $url = esc_url_raw( 'https://graph.facebook.com/me/accounts?limit=500&access_token=' . $valid_new_access_token );
4909
  $pages_data_connection = wp_remote_get( $url );
4910
 
@@ -4927,8 +4948,9 @@ function cff_oembeds_page() {
4927
  <?php if ( ! $saved_access_token_data && ! $valid_new_access_token && ! CFF_Oembed::can_do_oembed() ) {
4928
  if ( $access_token_error ) { ?>
4929
  <p><?php _e("There was a problem with the access token that was retrieved.", "custom-facebook-feed"); ?></p>
4930
- <?php }
4931
- $token_href = 'https://api.smashballoon.com/facebook-login.php?state=' . $admin_url_state;
 
4932
  if ( class_exists( 'SB_Instagram_Oembed' ) ) {
4933
  $sbi_oembed_token = SB_Instagram_Oembed::last_access_token();
4934
 
@@ -4967,7 +4989,7 @@ function cff_oembeds_page() {
4967
  </p>
4968
  <p style="text-align: center;">
4969
  <a style="display: inline-block; float: none; margin-bottom: 0;" href="https://smashballoon.com/doc/how-to-prevent-your-oembed-access-token-from-expiring/?facebook" class="cff_admin_btn" target="blank" rel="noopener"><?php _e( 'How to Create a Facebook Page', 'custom-facebook-feed' ); ?></a>
4970
- &nbsp;&nbsp;<a href="https://api.smashballoon.com/facebook-login.php?state=<?php echo $admin_url_state; ?>" class="button button-secondary" style="height: 47px;line-height: 47px;font-size: 14px;padding: 0 21px;"><?php _e( 'Try Again', 'custom-facebook-feed' ); ?></a>
4971
  </p>
4972
 
4973
  <a href="JavaScript:void(0);" class="cff-modal-close"><i class="fa fa-times"></i></a>
@@ -5001,7 +5023,7 @@ function cff_oembeds_page() {
5001
  <?php echo sprintf( __( 'Facebook requires that users have a role on a Facebook page in order to create access tokens that don\'t expire. Visit %1sthis link%2s for instructions on extending your access token to never expire.', 'custom-facebook-feed' ), $link_1, $link_2 ); ?>
5002
  </p>
5003
  <p>
5004
- <a href="https://api.smashballoon.com/facebook-login.php?state=<?php echo $admin_url_state; ?>" class="cff_admin_btn" id="cff_fb_login"><i class="fa fa-facebook-square"></i> <?php _e( 'Connect to Facebook and Recheck Access Token', 'custom-facebook-feed' ); ?></a>
5005
  </p>
5006
  </div>
5007
 
@@ -5456,4 +5478,16 @@ function cff_oembed_disable() {
5456
 
5457
  die();
5458
  }
5459
- add_action( 'wp_ajax_cff_oembed_disable', 'cff_oembed_disable' );
 
 
 
 
 
 
 
 
 
 
 
 
4
  use CustomFacebookFeed\CFF_GDPR_Integrations;
5
  use CustomFacebookFeed\CFF_Feed_Locator;
6
 
7
+ add_action('group_post_scheduler_cron', 'cff_group_cache_function');
8
+ function cff_group_cache_function(){
9
+ CustomFacebookFeed\CFF_Group_Posts::cron_update_group_persistent_cache();
10
+ }
11
+
12
+
13
  //Create Style page
14
  function cff_style_page() {
15
  //Declare variables for fields
149
  'cff_app_id' => '',
150
  'cff_show_credit' => '',
151
  'cff_font_source' => '',
152
+ 'cff_enqueue_with_shortcode' => false,
153
  'cff_minify' => false,
154
  'disable_admin_notice' => false,
155
  'cff_sep_color' => '',
371
  $cff_disable_styles = $options[ 'cff_disable_styles' ];
372
  $cff_format_issue = $options[ 'cff_format_issue' ];
373
  $cff_restricted_page = $options[ 'cff_restricted_page' ];
374
+ $cff_enqueue_with_shortcode = $options[ 'cff_enqueue_with_shortcode' ];
375
  $cff_minify = $options[ 'cff_minify' ];
376
  $cff_cols = $options[ 'cff_cols' ];
377
  $cff_cols_mobile = $options[ 'cff_cols_mobile' ];
425
  $cff_ajax = 'cff_ajax';
426
  $cff_ajax_val = get_option( $cff_ajax );
427
 
 
428
  //Check nonce before saving data
429
  if ( ! isset( $_POST['cff_customize_nonce'] ) || ! wp_verify_nonce( $_POST['cff_customize_nonce'], 'cff_saving_customize' ) ) {
430
  //Nonce did not verify
794
  (isset($_POST[ 'cff_disable_styles' ])) ? $cff_disable_styles = sanitize_text_field( $_POST[ 'cff_disable_styles' ] ) : $cff_disable_styles = '';
795
  (isset($_POST[ 'cff_format_issue' ])) ? $cff_format_issue = sanitize_text_field( $_POST[ 'cff_format_issue' ] ) : $cff_format_issue = '';
796
  (isset($_POST[ 'cff_restricted_page' ])) ? $cff_restricted_page = sanitize_text_field( $_POST[ 'cff_restricted_page' ] ) : $cff_restricted_page = '';
797
+ (isset($_POST[ 'cff_enqueue_with_shortcode' ])) ? $cff_enqueue_with_shortcode = $_POST[ 'cff_enqueue_with_shortcode' ] : $cff_enqueue_with_shortcode = '';
798
  (isset($_POST[ 'cff_minify' ])) ? $cff_minify = sanitize_text_field( $_POST[ 'cff_minify' ] ) : $cff_minify = '';
799
  (isset($_POST[ 'cff_disable_admin_notice' ])) ? $cff_disable_admin_notice = sanitize_text_field( $_POST[ 'cff_disable_admin_notice' ] ) : $cff_disable_admin_notice = '';
800
 
818
  $options[ 'cff_disable_styles' ] = $cff_disable_styles;
819
  $options[ 'cff_format_issue' ] = $cff_format_issue;
820
  $options[ 'cff_restricted_page' ] = $cff_restricted_page;
821
+ $options[ 'cff_enqueue_with_shortcode' ] = $cff_enqueue_with_shortcode;
822
  $options[ 'cff_minify' ] = $cff_minify;
823
  $options[ 'disable_admin_notice' ] = $cff_disable_admin_notice;
824
 
828
  if( $cff_cron == 'yes' ){
829
  //Clear the existing cron event
830
  wp_clear_scheduled_hook('cff_cron_job');
 
831
  $cff_cache_time = get_option( 'cff_cache_time' );
832
+ $cff_cache_time_unit = get_option( 'cff_cache_time_unit' );
 
 
 
 
 
833
 
834
+ //Set the event schedule based on what the caching time is set to
835
+ $cff_cron_schedule = 'hourly';
836
+ if( $cff_cache_time_unit == 'hours' && $cff_cache_time > 5 ) $cff_cron_schedule = 'twicedaily';
837
+ if( $cff_cache_time_unit == 'days' ) $cff_cron_schedule = 'daily';
838
  wp_schedule_event(time(), $cff_cron_schedule, 'cff_cron_job');
839
  }
840
 
3040
  </td>
3041
  </tr>
3042
 
3043
+ <tr>
3044
+ <th class="bump-left"><label class="bump-left"><?php _e("Enqueue CSS/JS with the shortcode"); ?></label></th>
3045
+ <td>
3046
+ <input name="cff_enqueue_with_shortcode" type="checkbox" id="cff_enqueue_with_shortcode" <?php if($cff_enqueue_with_shortcode == true) echo "checked"; ?> />
3047
+ <a class="cff-tooltip-link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'custom-facebook-feed'); ?></a>
3048
+ <p class="cff-tooltip cff-more-info"><?php _e("Check this box if you'd like to only include the CSS and JS files for the plugin when the feed is on the page.", 'custom-facebook-feed'); ?></p>
3049
+ </td>
3050
+ </tr>
3051
+
3052
  <tr>
3053
  <th class="bump-left"><label class="bump-left"><?php _e("Minify CSS and JavaScript files"); ?></label></th>
3054
  <td>
3432
  if ( ! isset( $_POST['cff_settings_nonce'] ) || ! wp_verify_nonce( $_POST['cff_settings_nonce'], 'cff_saving_settings' ) ) {
3433
  //Nonce did not verify
3434
  } else {
3435
+
3436
  // See if the user has posted us some information. If they did, this hidden field will be set to 'Y'.
3437
  if( isset($_POST[ $hidden_field_name ]) && $_POST[ $hidden_field_name ] == 'Y' ) {
3438
  // Read their posted value
3467
  $options[ 'cff_timezone' ] = $cff_timezone;
3468
  $options[ 'cff_num_mobile' ] = $cff_num_mobile;
3469
  update_option( 'cff_style_settings', $options );
3470
+ $cff_cron_schedule = 'hourly';
3471
+ if( $cff_cache_time_unit_val == 'hours' && $cff_cache_time_val > 5 ) $cff_cron_schedule = 'twicedaily';
3472
+ if( $cff_cache_time_unit_val == 'days' ) $cff_cron_schedule = 'daily';
3473
+ CustomFacebookFeed\CFF_Group_Posts::group_reschedule_event(time(), $cff_cron_schedule);
3474
 
3475
  //Delete ALL transients
3476
  cff_delete_cache();
3549
  $admin_url_state = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
3550
  }
3551
  ?>
3552
+ <a href="https://api.smashballoon.com/v2/v2/facebook-login.php?state=<?php echo $admin_url_state; ?>" class="cff_admin_btn" id="cff_page_app"><i class="fa fa-facebook-square"></i> <?php _e( 'Continue', 'custom-facebook-feed' ); ?></a>
3553
 
3554
+ <a href="https://api.smashballoon.com/v2/facebook-group-login.php?state=<?php echo $admin_url_state; ?>" class="cff_admin_btn" id="cff_group_app"><i class="fa fa-facebook-square"></i> <?php _e( 'Continue', 'custom-facebook-feed' ); ?></a>
3555
 
3556
  </p>
3557
  </div>
3565
 
3566
 
3567
  <?php
3568
+ if( isset($_GET['cff_access_token']) && isset($_GET['cff_final_response']) ){
 
 
3569
 
3570
+ if( $_GET['cff_final_response'] == 'true' ) {
3571
 
3572
  \cff_main()->cff_error_reporter->remove_error( 'connection' );
3573
  \cff_main()->cff_error_reporter->add_action_log( 'Connection or updating account');
3574
 
3575
+ $access_token = $_GET['cff_access_token'];
3576
  $cff_is_groups = false;
3577
  $pages_data_arr = '';
3578
  $groups_data_arr = '';
3579
 
3580
+ if( isset($_GET['cff_group']) ){
3581
  //Get Groups
3582
 
3583
  $cff_is_groups = true;
3781
  <?php
3782
  //When connecting an account check the current access token to see if it has an error. If so then add a class to the field and replace it automatically in JS when getting a new one.
3783
  $cff_replace_token = false;
3784
+ if( isset($_GET['cff_access_token']) && isset($_GET['cff_final_response']) ){
3785
 
3786
+ if( $_GET['cff_final_response'] == 'true' ){
3787
  $api_page_id = trim($page_id_val);
3788
  $url = 'https://graph.facebook.com/'.$api_page_id.'?limit=1&fields=id&access_token='.$access_token_val;
3789
  $accounts_data = CFF_Utils::cff_fetchUrl($url);
4591
 
4592
  ?>
4593
  </textarea>
4594
+ <div style="margin-bottom: 20px;"><input id="cff_reset_log" class="button-secondary" type="submit" value="<?php esc_attr_e( 'Reset Error Log' ); ?>" style="vertical-align: middle;"/></div>
4595
 
4596
  <?php } //End support tab
4597
 
4916
  $access_token_error = false;
4917
  $valid_new_access_token = false;
4918
  $show_token_expiration_modal = false;
4919
+ if ( ! empty( $_GET['cff_access_token'] ) && strlen( $_GET['cff_access_token'] ) <= 20 ) {
4920
  $access_token_error = true;
4921
  } elseif ( ! empty( $_GET['transfer'] ) ) {
4922
  if ( class_exists( 'SB_Instagram_Oembed' ) ) {
4924
  $valid_new_access_token = $sbi_oembed_token;
4925
  }
4926
  } else {
4927
+ $valid_new_access_token = ! empty( $_GET['cff_access_token'] ) && strlen( $_GET['cff_access_token'] ) > 20 && $saved_access_token_data !== $_GET['cff_access_token'] ? sanitize_text_field( $_GET['cff_access_token'] ) : false;
4928
+ if ( $valid_new_access_token && ! empty( $_GET['cff_access_token'] ) ) {
4929
  $url = esc_url_raw( 'https://graph.facebook.com/me/accounts?limit=500&access_token=' . $valid_new_access_token );
4930
  $pages_data_connection = wp_remote_get( $url );
4931
 
4948
  <?php if ( ! $saved_access_token_data && ! $valid_new_access_token && ! CFF_Oembed::can_do_oembed() ) {
4949
  if ( $access_token_error ) { ?>
4950
  <p><?php _e("There was a problem with the access token that was retrieved.", "custom-facebook-feed"); ?></p>
4951
+
4952
+ <?php }
4953
+ $token_href = 'https://api.smashballoon.com/v2/facebook-login.php?state=' . $admin_url_state;
4954
  if ( class_exists( 'SB_Instagram_Oembed' ) ) {
4955
  $sbi_oembed_token = SB_Instagram_Oembed::last_access_token();
4956
 
4989
  </p>
4990
  <p style="text-align: center;">
4991
  <a style="display: inline-block; float: none; margin-bottom: 0;" href="https://smashballoon.com/doc/how-to-prevent-your-oembed-access-token-from-expiring/?facebook" class="cff_admin_btn" target="blank" rel="noopener"><?php _e( 'How to Create a Facebook Page', 'custom-facebook-feed' ); ?></a>
4992
+ &nbsp;&nbsp;<a href="https://api.smashballoon.com/v2/facebook-login.php?state=<?php echo $admin_url_state; ?>" class="button button-secondary" style="height: 47px;line-height: 47px;font-size: 14px;padding: 0 21px;"><?php _e( 'Try Again', 'custom-facebook-feed' ); ?></a>
4993
  </p>
4994
 
4995
  <a href="JavaScript:void(0);" class="cff-modal-close"><i class="fa fa-times"></i></a>
5023
  <?php echo sprintf( __( 'Facebook requires that users have a role on a Facebook page in order to create access tokens that don\'t expire. Visit %1sthis link%2s for instructions on extending your access token to never expire.', 'custom-facebook-feed' ), $link_1, $link_2 ); ?>
5024
  </p>
5025
  <p>
5026
+ <a href="https://api.smashballoon.com/v2/facebook-login.php?state=<?php echo $admin_url_state; ?>" class="cff_admin_btn" id="cff_fb_login"><i class="fa fa-facebook-square"></i> <?php _e( 'Connect to Facebook and Recheck Access Token', 'custom-facebook-feed' ); ?></a>
5027
  </p>
5028
  </div>
5029
 
5478
 
5479
  die();
5480
  }
5481
+ add_action( 'wp_ajax_cff_oembed_disable', 'cff_oembed_disable' );
5482
+
5483
+ function cff_clear_error_log() {
5484
+
5485
+ \cff_main()->cff_error_reporter->remove_all_errors();
5486
+
5487
+ cff_delete_cache();
5488
+
5489
+ echo "1";
5490
+
5491
+ die();
5492
+ }
5493
+ add_action( 'wp_ajax_cff_clear_error_log', 'cff_clear_error_log' );
admin/assets/js/cff-admin-scripts.js CHANGED
@@ -983,6 +983,34 @@ jQuery(document).ready(function($) {
983
  jQuery(this).closest('td').find('.cff-condensed-wrap').hide();
984
  jQuery(this).remove();
985
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
986
  });
987
 
988
 
983
  jQuery(this).closest('td').find('.cff-condensed-wrap').hide();
984
  jQuery(this).remove();
985
  });
986
+
987
+
988
+ //cff_reset_log
989
+ var $cffClearLog = $('#cff_reset_log');
990
+
991
+ $cffClearLog.on('click', function(event) {
992
+ event.preventDefault();
993
+
994
+ jQuery('#cff-clear-cache-success').remove();
995
+ jQuery(this).prop("disabled",true);
996
+
997
+ $.ajax({
998
+ url : cffA.ajax_url,
999
+ type : 'post',
1000
+ data : {
1001
+ action : 'cff_clear_error_log'
1002
+ },
1003
+ success : function(data) {
1004
+ $cffClearLog.prop('disabled',false);
1005
+ if(data=='1') {
1006
+ $cffClearLog.after('<i id="cff-clear-cache-success" class="fa fa-check-circle cff-success"></i>');
1007
+ } else {
1008
+ $cffClearLog.after('<span>error</span>');
1009
+ }
1010
+ }
1011
+ }); // ajax call
1012
+ }); // clear_error_log click
1013
+
1014
  });
1015
 
1016
 
admin/templates/locator-summary.php CHANGED
@@ -34,37 +34,51 @@ if ( ! empty( $locator_summary ) ) : ?>
34
  </thead>
35
  <tbody>
36
 
37
- <?php foreach ( $locator_section['results'] as $result ) :
38
- $shortcode_atts = $result['shortcode_atts'] != '[""]' ? json_decode( $result['shortcode_atts'], true ) : [];
39
- $shortcode_atts = is_array( $shortcode_atts ) ? $shortcode_atts : array();
40
- $display_terms = CFF_FB_Settings::feed_type_and_terms_display( $connected_accounts, $result, $database_settings );
41
- $comma_separated = implode(',',$display_terms['name']);
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
- $display = $comma_separated;
44
- if ( strlen( $comma_separated ) > 31 ) {
45
- $display = '<span class="cff-condensed-wrap">' . substr( $comma_separated, 0, 30 ) . '<a class="cff-locator-more" href="JavaScript:void(0);">...</a></span>';
46
- $comma_separated = '<span class="cff-full-wrap">' . esc_html( $comma_separated ) . '</span>';
47
- } else {
48
- $comma_separated = '';
49
- }
50
- $type = implode(',',$display_terms['type']);
51
 
52
- $full_shortcode_string = '[custom-facebook-feed';
53
- foreach ( $shortcode_atts as $key => $value ) {
54
- $full_shortcode_string .= ' ' . esc_html( $key ) . '="' . esc_html( $value ) . '"';
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  }
56
- $full_shortcode_string .= ']';
57
- ?>
58
- <tr>
59
- <td><?php echo esc_html( $type ); ?></td>
60
- <td><?php echo $display . $comma_separated; ?></td>
61
- <td>
62
- <span class="cff-condensed-wrap"><a class="cff-locator-more" href="JavaScript:void(0);"><?php esc_html_e( 'Show', 'custom-facebook-feed' ); ?></a></span>
63
- <span class="cff-full-wrap"><?php echo $full_shortcode_string; ?></span>
64
- </td>
65
- <td><a href="<?php echo esc_url( get_the_permalink( $result['post_id'] ) ); ?>" target="_blank" rel="noopener"><?php echo esc_html( get_the_title( $result['post_id'] ) ); ?></a></td>
66
- </tr>
67
- <?php endforeach; ?>
68
 
69
 
70
  </tbody>
34
  </thead>
35
  <tbody>
36
 
37
+ <?php
38
+ $atts_for_page = array();
39
+ foreach ( $locator_section['results'] as $result ) :
40
+ $should_add = true;
41
+ if ( ! empty( $atts_for_page[ $result['post_id'] ] ) ) {
42
+ foreach ( $atts_for_page[ $result['post_id'] ] as $existing_atts ) {
43
+ if ( $existing_atts === $result['shortcode_atts'] ) {
44
+ $should_add = false;
45
+ }
46
+ }
47
+ }
48
+ if ( $should_add ) {
49
+ $atts_for_page[ $result['post_id'] ][] = $result['shortcode_atts'];
50
+ $shortcode_atts = $result['shortcode_atts'] != '[""]' ? json_decode( $result['shortcode_atts'], true ) : [];
51
+ $shortcode_atts = is_array( $shortcode_atts ) ? $shortcode_atts : array();
52
+ $display_terms = CFF_FB_Settings::feed_type_and_terms_display( $connected_accounts, $result, $database_settings );
53
+ $comma_separated = implode(',',$display_terms['name']);
54
 
55
+ $display = $comma_separated;
56
+ if ( strlen( $comma_separated ) > 31 ) {
57
+ $display = '<span class="cff-condensed-wrap">' . substr( $comma_separated, 0, 30 ) . '<a class="cff-locator-more" href="JavaScript:void(0);">...</a></span>';
58
+ $comma_separated = '<span class="cff-full-wrap">' . esc_html( $comma_separated ) . '</span>';
59
+ } else {
60
+ $comma_separated = '';
61
+ }
62
+ $type = implode(',',$display_terms['type']);
63
 
64
+ $full_shortcode_string = '[custom-facebook-feed';
65
+ foreach ( $shortcode_atts as $key => $value ) {
66
+ $full_shortcode_string .= ' ' . esc_html( $key ) . '="' . esc_html( $value ) . '"';
67
+ }
68
+ $full_shortcode_string .= ']';
69
+ ?>
70
+ <tr>
71
+ <td><?php echo esc_html( $type ); ?></td>
72
+ <td><?php echo $display . $comma_separated; ?></td>
73
+ <td>
74
+ <span class="cff-condensed-wrap"><a class="cff-locator-more" href="JavaScript:void(0);"><?php esc_html_e( 'Show', 'custom-facebook-feed' ); ?></a></span>
75
+ <span class="cff-full-wrap"><?php echo $full_shortcode_string; ?></span>
76
+ </td>
77
+ <td><a href="<?php echo esc_url( get_the_permalink( $result['post_id'] ) ); ?>" target="_blank" rel="noopener"><?php echo esc_html( get_the_title( $result['post_id'] ) ); ?></a></td>
78
+ </tr>
79
+ <?php
80
  }
81
+ endforeach; ?>
 
 
 
 
 
 
 
 
 
 
 
82
 
83
 
84
  </tbody>
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: 2.19
7
  Author: Smash Balloon
8
  Author URI: http://smashballoon.com/
9
  License: GPLv2 or later
@@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
  */
26
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
27
 
28
- define('CFFVER', '2.19');
29
 
30
  // Db version.
31
  if ( ! defined( 'CFF_DBVERSION' ) ) {
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: 2.19.1
7
  Author: Smash Balloon
8
  Author URI: http://smashballoon.com/
9
  License: GPLv2 or later
25
  */
26
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
27
 
28
+ define('CFFVER', '2.19.1');
29
 
30
  // Db version.
31
  if ( ! defined( 'CFF_DBVERSION' ) ) {
inc/CFF_FB_Settings.php CHANGED
@@ -67,6 +67,7 @@ class CFF_FB_Settings {
67
  'ajax' => get_option('cff_ajax'),
68
  'offset' => '',
69
  'account' => '',
 
70
 
71
  //General
72
  'width' => isset($options[ 'cff_feed_width' ]) ? $options[ 'cff_feed_width' ] : '',
@@ -185,6 +186,7 @@ class CFF_FB_Settings {
185
  'textissue' => isset($options[ 'cff_format_issue' ]) ? $options[ 'cff_format_issue' ] : '',
186
  'restrictedpage' => isset($options[ 'cff_restricted_page' ]) ? $options[ 'cff_restricted_page' ] : '',
187
  'salesposts' => 'false',
 
188
 
189
  //Page Header
190
  'showheader' => isset($options[ 'cff_show_header' ]) ? $options[ 'cff_show_header' ] : '',
@@ -300,7 +302,7 @@ class CFF_FB_Settings {
300
  $cff_connected_accounts = get_option('cff_connected_accounts');
301
  $cff_connected_accounts = json_decode( str_replace('\"','"', $cff_connected_accounts) );
302
  if( !empty( $cff_account ) ){
303
- if( !empty($cff_connected_accounts) ){
304
  //Grab the ID and token from the connected accounts setting
305
  $id_and_token = [
306
  'id' => $cff_connected_accounts->{ $cff_account }->{'id'},
@@ -357,7 +359,7 @@ class CFF_FB_Settings {
357
  if(!in_array($account_info['pagetype'], $types)){
358
  array_push($types, $account_info['pagetype']);
359
  }
360
- $account_name = ($account_info['name'] != '') ? urldecode($account_info['name']) : $feed_id;
361
  array_push($names, $account_name);
362
 
363
  }
67
  'ajax' => get_option('cff_ajax'),
68
  'offset' => '',
69
  'account' => '',
70
+ 'cff_enqueue_with_shortcode' => isset($options[ 'cff_enqueue_with_shortcode' ]) ? $options[ 'cff_enqueue_with_shortcode' ] : false,
71
 
72
  //General
73
  'width' => isset($options[ 'cff_feed_width' ]) ? $options[ 'cff_feed_width' ] : '',
186
  'textissue' => isset($options[ 'cff_format_issue' ]) ? $options[ 'cff_format_issue' ] : '',
187
  'restrictedpage' => isset($options[ 'cff_restricted_page' ]) ? $options[ 'cff_restricted_page' ] : '',
188
  'salesposts' => 'false',
189
+ 'storytags' => 'false',
190
 
191
  //Page Header
192
  'showheader' => isset($options[ 'cff_show_header' ]) ? $options[ 'cff_show_header' ] : '',
302
  $cff_connected_accounts = get_option('cff_connected_accounts');
303
  $cff_connected_accounts = json_decode( str_replace('\"','"', $cff_connected_accounts) );
304
  if( !empty( $cff_account ) ){
305
+ if( !empty($cff_connected_accounts) && isset($cff_connected_accounts->{ $cff_account }) ){
306
  //Grab the ID and token from the connected accounts setting
307
  $id_and_token = [
308
  'id' => $cff_connected_accounts->{ $cff_account }->{'id'},
359
  if(!in_array($account_info['pagetype'], $types)){
360
  array_push($types, $account_info['pagetype']);
361
  }
362
+ $account_name = (isset($account_info['name']) && $account_info['name'] != '') ? urldecode($account_info['name']) : $feed_id;
363
  array_push($names, $account_name);
364
 
365
  }
inc/CFF_Feed_Locator.php CHANGED
@@ -119,7 +119,8 @@ class CFF_Feed_Locator{
119
  foreach ( $this->matching_entries as $index => $matching_entry ) {
120
  $shortcode_atts = json_decode( $matching_entry['shortcode_atts'], true );
121
  $shortcode_atts = ( $shortcode_atts == null) ? [] : $shortcode_atts;
122
- $atts_diff = array_diff($shortcode_atts , $this->feed_details['atts'] ); // determines if the shortcode settings match the shortcode settings of an existing feed
 
123
  if ( empty( $atts_diff ) ) {
124
  $matching_indices[] = $matching_entry['id'];
125
  if ( $matching_entry['html_location'] === $this->feed_details['location']['html'] ) {
119
  foreach ( $this->matching_entries as $index => $matching_entry ) {
120
  $shortcode_atts = json_decode( $matching_entry['shortcode_atts'], true );
121
  $shortcode_atts = ( $shortcode_atts == null) ? [] : $shortcode_atts;
122
+ $atts = is_array( $this->feed_details['atts'] ) ? $this->feed_details['atts'] : array();
123
+ $atts_diff = array_diff($shortcode_atts , $atts ); // determines if the shortcode settings match the shortcode settings of an existing feed
124
  if ( empty( $atts_diff ) ) {
125
  $matching_indices[] = $matching_entry['id'];
126
  if ( $matching_entry['html_location'] === $this->feed_details['location']['html'] ) {
inc/CFF_Group_Posts.php ADDED
@@ -0,0 +1,388 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class CFF_Groups_Post
4
+ *
5
+ *
6
+ *
7
+ * @since 3.19.3
8
+ */
9
+ namespace CustomFacebookFeed;
10
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
11
+
12
+
13
+ class CFF_Group_Posts{
14
+
15
+ /**
16
+ * @var string
17
+ */
18
+ private $cache_name;
19
+
20
+ /**
21
+ * @var string
22
+ */
23
+ private $api_call_url;
24
+
25
+ /**
26
+ * @var string
27
+ */
28
+ private $data_att_html;
29
+
30
+ /**
31
+ * @var array
32
+ */
33
+ private $posts_array;
34
+
35
+ /**
36
+ * @var array
37
+ */
38
+ private $json_data;
39
+
40
+ /**
41
+ * @var array
42
+ */
43
+ private $posts_cache_data;
44
+
45
+ /**
46
+ * @var array
47
+ */
48
+ private $feed_options;
49
+
50
+ /**
51
+ * @var int
52
+ */
53
+ private $next_urls_arr_safe;
54
+
55
+ /**
56
+ * @var bool
57
+ */
58
+ private $is_event_page;
59
+
60
+
61
+
62
+
63
+ /**
64
+ * Construct.
65
+ *
66
+ * Construct Caching System
67
+ *
68
+ * @since 3.19.3
69
+ * @access public
70
+ */
71
+ function __construct($group_id, $feed_options, $api_call_url, $data_att_html,$is_event_page) {
72
+ $this->cache_name = '!cff_group_'. $group_id . '_' . str_replace(',', '_', $feed_options['type']);
73
+ $this->posts_cache_data = get_option($this->cache_name);
74
+ $this->feed_options = $feed_options;
75
+ $this->api_call_url = $api_call_url;
76
+ #$this->api_call_url = $api_call_url . '&limit=100';
77
+
78
+ $this->data_att_html = $data_att_html;
79
+ $this->is_event_page = $is_event_page;
80
+ if(!$this->posts_cache_data){
81
+ $this->posts_cache_data = new \stdClass();
82
+ $this->posts_cache_data->api_url = $this->api_call_url;
83
+ $this->posts_cache_data->shortcode_options = $this->data_att_html;
84
+ $this->posts_cache_data->data = [];
85
+ }else{
86
+ $this->posts_cache_data = json_decode($this->posts_cache_data);
87
+ }
88
+
89
+ }
90
+
91
+
92
+ /**
93
+ *
94
+ * @since 3.19.3
95
+ * Returns Needed Information for the Group Posts
96
+ *
97
+ * @access public
98
+ */
99
+ function init_group_posts($json_data, $load_more_date, $show_posts){
100
+ $this->json_data = json_decode($json_data);
101
+ $this->json_data = (isset($this->json_data->data) && $this->json_data->data > 0) ? $this->json_data->data : [];
102
+ $this->posts_array = isset($this->posts_cache_data->data) ? (array)$this->posts_cache_data->data : [];
103
+ $this->add_update_posts();
104
+ $this->update_cache();
105
+ $latest_record_date = CFF_Group_Posts::create_next_pagination($this->json_data, $show_posts);
106
+ $load_from_cache = false;
107
+ if(sizeof($this->json_data) <= 0){
108
+ if($load_more_date === false){
109
+ $json_data = $this->get_data_json(false, null);
110
+ }else{
111
+ $json_data = $this->get_data_json(true, $load_more_date);
112
+ }
113
+ $latest_record_date = CFF_Group_Posts::create_next_pagination($this->posts_cache_data->data, $show_posts);
114
+ $load_from_cache = true;
115
+ }else{
116
+ $json_data_check = json_decode($json_data);
117
+ $json_data = $this->check_posts_returned($json_data_check, $show_posts);
118
+ $this->json_data = json_decode($json_data);
119
+ $this->json_data = (isset($this->json_data->data) && $this->json_data->data > 0) ? $this->json_data->data : [];
120
+ $latest_record_date = CFF_Group_Posts::create_next_pagination($this->json_data, $show_posts);
121
+ }
122
+
123
+ return [
124
+ 'posts_json' => $json_data,
125
+ 'latest_record_date' => $latest_record_date,
126
+ 'load_from_cache' => $load_from_cache
127
+ ];
128
+ }
129
+
130
+
131
+
132
+ /**
133
+ *
134
+ * @since 3.19.3
135
+ * Checks if the returned posts number from the API o the transient cache
136
+ * Is equal to the number of posts defined
137
+ * IF NOT it does look for the posts from the Persistent Cache
138
+ *
139
+ * @access public
140
+ */
141
+ function check_posts_returned($json_data, $show_posts){
142
+ if(isset($json_data->data)){
143
+ $prev_post = [];
144
+ $result_array = [];
145
+ foreach ($json_data->data as $single_post) {
146
+ $is_returned = !CFF_Group_Posts::check_duplicated_posts($prev_post, $single_post) && (!empty($single_post->message) || isset($single_post->call_to_action->type)) ;
147
+ $prev_post = $single_post;
148
+ if($is_returned){
149
+ array_push($result_array, $single_post);
150
+ }
151
+ }
152
+ $json_data->data = array_slice($result_array, 0, $show_posts);
153
+ if(sizeof($json_data->data) < $show_posts){
154
+ $remaining_num = $show_posts - sizeof($json_data->data);
155
+ $remaining_json_data = json_decode($this->get_data_json(true, CFF_Group_Posts::create_next_pagination($json_data->data, sizeof($json_data->data))));
156
+ $json_data->data = array_merge( $json_data->data, $remaining_json_data->data );
157
+ }
158
+ }
159
+ return json_encode($json_data);
160
+ }
161
+
162
+
163
+
164
+ /**
165
+ *
166
+ * @since 3.19.3
167
+ * Add more POSTS to the Post array
168
+ * It can add or update
169
+ * @access public
170
+ */
171
+ function add_update_posts(){
172
+ $new_cached_posts = $this->posts_array;
173
+ $posts_array_api = $this->json_data;
174
+ foreach ($posts_array_api as $single_post) {
175
+ if(isset($single_post->id) && ( $this->is_event_page || (!empty($single_post->message) || isset($single_post->call_to_action->type) ) ) ){
176
+ $key = array_search($single_post->id, array_column($this->posts_array , 'id'));
177
+ if($key !== false){
178
+ $new_cached_posts[$key] = $single_post;
179
+ }else{
180
+ array_push($new_cached_posts, $single_post);
181
+ }
182
+ }
183
+ }
184
+ $this->posts_array = $new_cached_posts;
185
+ }
186
+
187
+
188
+ /**
189
+ *
190
+ * @since 3.19.3
191
+ * @access public
192
+ */
193
+ function get_data_json($is_load_more, $next_urls_arr_safe){
194
+ if($is_load_more && isset($next_urls_arr_safe)){
195
+ $this->next_urls_arr_safe = $next_urls_arr_safe;
196
+ $new_array = array_filter($this->posts_cache_data->data, function($single_post){
197
+ $the_time = isset($single_post->updated_time) ? $single_post->updated_time : $single_post->created_time;
198
+ $is_returned = ( (int)strtotime($the_time) < (int)$this->next_urls_arr_safe ) &&
199
+ ( !empty($single_post->message) || isset($single_post->call_to_action->type) );
200
+ return $is_returned;
201
+ });
202
+ $latest_record = end($this->posts_cache_data->data);
203
+ $new_array = array_slice($new_array , 0, $this->feed_options['num']);
204
+ $this->posts_cache_data->data = sizeof($new_array) > 0 ? $new_array : [];
205
+ if($latest_record == end($this->posts_cache_data->data)){
206
+ $this->posts_cache_data->no_more = true;
207
+ }
208
+ }else{
209
+ $this->posts_cache_data->data = array_slice($this->posts_cache_data->data,
210
+ 0, $this->feed_options['num']
211
+ );
212
+ }
213
+
214
+ return json_encode($this->posts_cache_data);
215
+ }
216
+
217
+
218
+
219
+
220
+ /**
221
+ * Save latest 100 posts
222
+ *
223
+ * @since 3.19.3
224
+ * @access public
225
+ */
226
+ function update_cache(){
227
+ usort($this->posts_array , function($post_1, $post_2){
228
+ $time_1 = isset($post_1->updated_time) ? $post_1->updated_time : $post_1->created_time;
229
+ $time_2 = isset($post_2->updated_time) ? $post_2->updated_time : $post_2->created_time;
230
+ return strcmp(strtotime($time_2), strtotime($time_1));
231
+ });
232
+ $this->posts_cache_data->is_event_page = $this->is_event_page;
233
+ $this->posts_cache_data->data = array_slice( $this->posts_array, 0, 100 );
234
+ if(sizeof($this->posts_array) > 0){
235
+ update_option( $this->cache_name, json_encode($this->posts_cache_data), false );
236
+ }
237
+
238
+ }
239
+
240
+ /**
241
+ * Get The pagination Values
242
+ *
243
+ * @since 3.19.3
244
+ * @access public
245
+ */
246
+
247
+ static function check_duplicated_posts($prev_post, $ac_post){
248
+ $ac_message = isset($ac_post->message) ? $ac_post->message : '';
249
+ $ac_link = isset($ac_post->link) ? $ac_post->link : '';
250
+ $ac_description = isset($ac_post->description) ? $ac_post->description : '';
251
+
252
+ $prev_message = isset($prev_post->message) ? $prev_post->message : '';
253
+ $prev_link = isset($prev_post->link) ? $prev_post->link : '';
254
+ $prev_description = isset($prev_post->description) ? $prev_post->description : '';
255
+ $is_duplicate = (($prev_message == $ac_message) && ($prev_link == $ac_link) && ($prev_description == $ac_description)) ? true : false;
256
+ return $is_duplicate;
257
+ }
258
+
259
+ static function create_next_pagination( $json_data_arr,$show_posts ){
260
+ if(isset($json_data_arr) && sizeof((array)$json_data_arr) > 0){
261
+ $result_array = [];
262
+ $prev_post = [];
263
+ foreach ($json_data_arr as $single_post) {
264
+ $is_returned = (!CFF_Group_Posts::check_duplicated_posts($prev_post, $single_post));
265
+ if($is_returned){
266
+ array_push($result_array, $single_post);
267
+ }
268
+ $prev_post = $single_post;
269
+ }
270
+ $json_data_arr = array_slice($result_array,0,$show_posts);
271
+ $latest_one = end($json_data_arr);
272
+ return isset($latest_one->updated_time) ? strtotime($latest_one->updated_time) : strtotime($latest_one->created_time);
273
+ }
274
+ return 0;
275
+ }
276
+
277
+
278
+ /*
279
+ API CALL FUNCTIONS *CRON JOB*
280
+ */
281
+ /**
282
+ *
283
+ * @since 3.19.3
284
+ * Cron to Update the Persistent Cache for Group Posts
285
+ * Get the latest 100 Posts from groups and Update in
286
+ * @access public
287
+ */
288
+ static function cron_update_group_persistent_cache(){
289
+ global $wpdb;
290
+ $table_name = $wpdb->prefix . "options";
291
+ $persistent_groups = $wpdb->get_results( "
292
+ SELECT `option_name` AS `name`, `option_value` AS `value`
293
+ FROM $table_name
294
+ WHERE `option_name` LIKE ('%!cff\_group\_%')
295
+ " );
296
+ foreach ($persistent_groups as $group) {
297
+ $group_json = json_decode($group->value, true);
298
+ CFF_Group_Posts::update_or_add_group($group->name, $group_json);
299
+ }
300
+ }
301
+
302
+ /**
303
+ * Save latest 100 posts
304
+ *
305
+ * @since 3.19.3
306
+ * @access public
307
+ */
308
+ static function update_or_add_group($cache_name, $group_cache){
309
+ $api_url = $group_cache['api_url'];
310
+ $cached_posts = $group_cache['data'];
311
+ $is_event_page = isset($group_cache['is_event_page']) ? $group_cache['is_event_page'] : false;
312
+ $data_att_html = $group_cache['shortcode_options'];
313
+ $new_cached_posts = $cached_posts;
314
+
315
+ $posts_array_api = json_decode(CFF_Group_Posts::api_call($api_url, $data_att_html));
316
+ foreach ($posts_array_api->data as $single_post) {
317
+ if(isset($single_post->id) && ( $is_event_page || (!empty($single_post->message) || isset($single_post->call_to_action->type) ) ) ){
318
+ $key = array_search($single_post->id, array_column($cached_posts , 'id'));
319
+ if($key !== false){
320
+ $new_cached_posts[$key] = $single_post;
321
+ }else{
322
+ array_push($new_cached_posts, $single_post);
323
+ }
324
+ }
325
+ }
326
+
327
+ $posts_cache_data = new \stdClass();
328
+ $posts_cache_data->api_url = $api_url;
329
+ $posts_cache_data->shortcode_options = $data_att_html;
330
+ $posts_cache_data->is_event_page = $is_event_page;
331
+ usort($new_cached_posts , function($post_1, $post_2){
332
+ $time_1 = isset($post_1->updated_time) ? $post_1->updated_time : $post_1->created_time;
333
+ $time_2 = isset($post_2->updated_time) ? $post_2->updated_time : $post_2->created_time;
334
+ return strcmp(strtotime($time_2), strtotime($time_1));
335
+ });
336
+ $new_cached_posts = array_slice( $new_cached_posts, 0, 100 );
337
+ $posts_cache_data->data = $new_cached_posts;
338
+ if(sizeof($new_cached_posts) > 0){
339
+ update_option( $cache_name, json_encode($posts_cache_data), false );
340
+ }
341
+
342
+ }
343
+
344
+
345
+ /**
346
+ * Api Call to get 100 posts from Group
347
+ *
348
+ * @since 3.19.3
349
+ * @access public
350
+ */
351
+ static function api_call($api_url, $data_att_html){
352
+ $api_url_100 = $api_url . '&limit=100';
353
+ $posts_json = CFF_Utils::cff_fetchUrl( $api_url_100 );
354
+ $FBdata = json_decode($posts_json);
355
+ $prefix_data = '{"data":';
356
+ $cff_featured_post = (substr($posts_json, 0, strlen($prefix_data)) == $prefix_data) ? false : true;
357
+ $prefix = '{';
358
+ if (substr($posts_json, 0, strlen($prefix)) == $prefix) $posts_json = substr($posts_json, strlen($prefix));
359
+ $posts_json = '{"api_url":"'. $api_url .'", "shortcode_options":"'. $data_att_html .'", ' . $posts_json;
360
+ ( $cff_featured_post ) ? $FBdata = $FBdata : $FBdata = $FBdata->data;
361
+
362
+ if( !empty($FBdata) ) {
363
+ if( !isset($FBdata->error) ){
364
+ return $posts_json;
365
+ }
366
+ }
367
+
368
+ return '{"data":[]}';
369
+ }
370
+
371
+ static function group_schedule_event($cff_cache_cron_time_unix, $cff_cron_schedule){
372
+ if ( ! wp_next_scheduled( 'group_post_scheduler_cron' ) ) {
373
+ wp_schedule_event( $cff_cache_cron_time_unix, $cff_cron_schedule, 'group_post_scheduler_cron' );
374
+ }
375
+ }
376
+
377
+ static function group_reschedule_event($cff_cache_cron_time_unix, $cff_cron_schedule){
378
+ $timestamp = wp_next_scheduled( 'group_post_scheduler_cron' );
379
+ if ( $timestamp ) {
380
+ wp_clear_scheduled_hook( 'group_post_scheduler_cron' );
381
+ wp_unschedule_event( $timestamp , 'group_post_scheduler_cron' );
382
+ }
383
+ if ( ! wp_next_scheduled( 'group_post_scheduler_cron' ) ) {
384
+ wp_schedule_event( $cff_cache_cron_time_unix, $cff_cron_schedule, 'group_post_scheduler_cron' );
385
+ }
386
+ }
387
+
388
+ }
inc/CFF_Shortcode.php CHANGED
@@ -72,8 +72,10 @@ class CFF_Shortcode extends CFF_Shortcode_Display{
72
  //Is it SSL?
73
  $cff_ssl = is_ssl() ? '&return_ssl_resources=true' : '';
74
  $attachments_desc = ( $this->atts['salesposts'] == 'true' ) ? '' : ',description';
 
75
 
76
- $cff_posts_json_url = 'https://graph.facebook.com/v4.0/' . $this->page_id . '/' . $graph_query . '?fields=id,from{picture,id,name,link},message,message_tags,story,story_tags,status_type,created_time,backdated_time,call_to_action,attachments{title'. $attachments_desc . ',media_type,unshimmed_url,target{id},media{source}}&access_token=' . $this->access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale . $cff_ssl;
 
77
 
78
  if( $cff_show_access_token && strlen($this->access_token) > 130 ){
79
  //If using a Page Access Token then set caching time to be minimum of 5 minutes
@@ -236,7 +238,69 @@ class CFF_Shortcode extends CFF_Shortcode_Display{
236
 
237
  }
238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
 
 
 
240
 
241
  /**
242
  * Display.
@@ -252,6 +316,7 @@ class CFF_Shortcode extends CFF_Shortcode_Display{
252
  $id_and_token = $this->fb_feed_settings->get_id_and_token();
253
  $this->page_id = $id_and_token['id'];
254
  $this->access_token = $id_and_token['token'];
 
255
 
256
  #var_dump($this->atts);
257
 
@@ -261,6 +326,11 @@ class CFF_Shortcode extends CFF_Shortcode_Display{
261
  $access_token = $this->access_token;
262
  $page_id = $this->page_id;
263
 
 
 
 
 
 
264
  /********** GENERAL **********/
265
  $cff_page_type = $this->atts[ 'pagetype' ];
266
  ($cff_page_type == 'group') ? $cff_is_group = true : $cff_is_group = false;
@@ -334,6 +404,7 @@ class CFF_Shortcode extends CFF_Shortcode_Display{
334
 
335
  //Get show posts attribute. If not set then default to 25
336
  $show_posts = ( empty( $this->atts['num'] ) || $this->atts['num'] == 'undefined' ) ? 25 : $this->atts['num'];
 
337
 
338
  //If the 'Enter my own Access Token' box is unchecked then don't use the user's access token, even if there's one in the field
339
  get_option('cff_show_access_token') ? $cff_show_access_token = true : $cff_show_access_token = false;
@@ -434,7 +505,21 @@ class CFF_Shortcode extends CFF_Shortcode_Display{
434
  $cff_posts_array = array();
435
 
436
  //ALL POSTS
 
437
  $FBdata = $this->get_feed_json( $graph_query, $cff_post_limit, $cff_locale, $cff_show_access_token, $cache_seconds, $cff_cache_time, $show_posts_by );
 
 
 
 
 
 
 
 
 
 
 
 
 
438
 
439
  global $current_user;
440
  $user_id = $current_user->ID;
72
  //Is it SSL?
73
  $cff_ssl = is_ssl() ? '&return_ssl_resources=true' : '';
74
  $attachments_desc = ( $this->atts['salesposts'] == 'true' ) ? '' : ',description';
75
+ $story_tags = ( $this->atts['storytags'] == 'true' ) ? '' : ',story_tags';
76
 
77
+
78
+ $cff_posts_json_url = 'https://graph.facebook.com/v4.0/' . $this->page_id . '/' . $graph_query . '?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'. $attachments_desc . ',media_type,unshimmed_url,target{id},media{source}}&access_token=' . $this->access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale . $cff_ssl;
79
 
80
  if( $cff_show_access_token && strlen($this->access_token) > 130 ){
81
  //If using a Page Access Token then set caching time to be minimum of 5 minutes
238
 
239
  }
240
 
241
+ function cff_get_processed_options($feed_options){
242
+ $page_id = $feed_options['id'];
243
+ $cff_facebook_string = 'facebook.com';
244
+ ( stripos($page_id, $cff_facebook_string) !== false) ? $cff_page_id_url_check = true : $cff_page_id_url_check = false;
245
+ if ( $cff_page_id_url_check === true ) {
246
+ //Remove trailing slash if exists
247
+ $page_id = preg_replace('{/$}', '', $page_id);
248
+ //Get last part of url
249
+ $page_id = substr( $page_id, strrpos( $page_id, '/' )+1 );
250
+ }
251
+ //If the Page ID contains a query string at the end then remove it
252
+ if ( stripos( $page_id, '?') !== false ) $page_id = substr($page_id, 0, strrpos($page_id, '?'));
253
+
254
+ //Always remove slash from end of Page ID
255
+ $page_id = preg_replace('{/$}', '', $page_id);
256
+
257
+ //Update the page ID in the feed options array for use everywhere
258
+ $feed_options['id'] = $page_id;
259
+
260
+
261
+ //If an 'account' is specified then use that instead of the Page ID/token from the settings
262
+ $cff_account = trim($feed_options['account']);
263
+
264
+ if( !empty( $cff_account ) ){
265
+ $cff_connected_accounts = get_option('cff_connected_accounts');
266
+ if( !empty($cff_connected_accounts) ){
267
+
268
+ //Replace both single and double quotes before decoding
269
+ $cff_connected_accounts = str_replace('\"','"', $cff_connected_accounts);
270
+ $cff_connected_accounts = str_replace("\'","'", $cff_connected_accounts);
271
+
272
+ $cff_connected_accounts = json_decode( $cff_connected_accounts );
273
+
274
+ if ( isset( $cff_account ) && is_object( $cff_connected_accounts ) ) {
275
+ //Grab the ID and token from the connected accounts setting
276
+ if( isset( $cff_connected_accounts->{ $cff_account } ) ){
277
+ $feed_options['id'] = $cff_connected_accounts->{ $cff_account }->{'id'};
278
+ $feed_options['accesstoken'] = $cff_connected_accounts->{ $cff_account }->{'accesstoken'};
279
+ }
280
+
281
+ }
282
+
283
+ //Replace the encryption string in the Access Token
284
+ if (strpos($feed_options['accesstoken'], '02Sb981f26534g75h091287a46p5l63') !== false) {
285
+ $feed_options['accesstoken'] = str_replace("02Sb981f26534g75h091287a46p5l63","",$feed_options['accesstoken']);
286
+ }
287
+ }
288
+ }
289
+
290
+ //Replace the encryption string in the Access Token
291
+ if (strpos($feed_options['accesstoken'], '02Sb981f26534g75h091287a46p5l63') !== false) {
292
+ $feed_options['accesstoken'] = str_replace("02Sb981f26534g75h091287a46p5l63","",$feed_options['accesstoken']);
293
+ }
294
+ $cff_connected_accounts = get_option('cff_connected_accounts');
295
+ if(!empty($cff_connected_accounts)){
296
+ $connected_accounts = (array)json_decode(stripcslashes($cff_connected_accounts));
297
+ if(array_key_exists($feed_options['id'], $connected_accounts)){
298
+ $feed_options['pagetype'] = $connected_accounts[$feed_options['id']]->pagetype;
299
+ }
300
+ }
301
 
302
+ return $feed_options;
303
+ }
304
 
305
  /**
306
  * Display.
316
  $id_and_token = $this->fb_feed_settings->get_id_and_token();
317
  $this->page_id = $id_and_token['id'];
318
  $this->access_token = $id_and_token['token'];
319
+ $this->atts = $this->cff_get_processed_options( $this->atts );
320
 
321
  #var_dump($this->atts);
322
 
326
  $access_token = $this->access_token;
327
  $page_id = $this->page_id;
328
 
329
+ if ( $atts['cff_enqueue_with_shortcode'] === 'on' || $atts['cff_enqueue_with_shortcode'] === 'true' ) {
330
+ wp_enqueue_style( 'cff' );
331
+ wp_enqueue_script( 'cffscripts' );
332
+ }
333
+
334
  /********** GENERAL **********/
335
  $cff_page_type = $this->atts[ 'pagetype' ];
336
  ($cff_page_type == 'group') ? $cff_is_group = true : $cff_is_group = false;
404
 
405
  //Get show posts attribute. If not set then default to 25
406
  $show_posts = ( empty( $this->atts['num'] ) || $this->atts['num'] == 'undefined' ) ? 25 : $this->atts['num'];
407
+ $show_posts_number = isset( $this->atts['minnum'] ) ? $this->atts['minnum'] : $this->atts['num'];
408
 
409
  //If the 'Enter my own Access Token' box is unchecked then don't use the user's access token, even if there's one in the field
410
  get_option('cff_show_access_token') ? $cff_show_access_token = true : $cff_show_access_token = false;
505
  $cff_posts_array = array();
506
 
507
  //ALL POSTS
508
+
509
  $FBdata = $this->get_feed_json( $graph_query, $cff_post_limit, $cff_locale, $cff_show_access_token, $cache_seconds, $cff_cache_time, $show_posts_by );
510
+ if( $cff_is_group ){
511
+ $cff_ssl = is_ssl() ? '&return_ssl_resources=true' : '';
512
+ $attachments_desc = ( $this->atts['salesposts'] == 'true' ) ? '' : ',description';
513
+ $cff_posts_json_url = 'https://graph.facebook.com/v4.0/' . $this->page_id . '/' . $graph_query . '?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'. $attachments_desc . ',media_type,unshimmed_url,target{id},media{source}}&access_token=' . $this->access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale . $cff_ssl;
514
+ $this->atts['type'] = 'links_events_videos_photos_albums_statuses_';
515
+ $groups_post = new CFF_Group_Posts($this->page_id, $this->atts, $cff_posts_json_url, $data_att_html, false);
516
+ $groups_post_result = $groups_post->init_group_posts(json_encode($FBdata), false, $show_posts_number);
517
+ $posts_json = $groups_post_result['posts_json'];
518
+ $FBdata = json_decode($posts_json);
519
+ }
520
+
521
+
522
+
523
 
524
  global $current_user;
525
  $user_id = $current_user->ID;
inc/CFF_Shortcode_Display.php CHANGED
@@ -534,6 +534,9 @@ class CFF_Shortcode_Display {
534
 
535
  $cff_app_link = isset($news->call_to_action->value->app_link) ? $news->call_to_action->value->app_link : '';
536
 
 
 
 
537
  //Add the button to the post if the text isn't "NO_BUTTON"
538
  if( $cff_button_type != 'NO_BUTTON' ):
539
  ?>
534
 
535
  $cff_app_link = isset($news->call_to_action->value->app_link) ? $news->call_to_action->value->app_link : '';
536
 
537
+ // Set the message page cta to use the default messenger link as the API can sometimes send an invalid link
538
+ if ( $cff_button_type == 'MESSAGE_PAGE' ) $cff_cta_link = 'https://m.me/' . $news->from->id;
539
+
540
  //Add the button to the post if the text isn't "NO_BUTTON"
541
  if( $cff_button_type != 'NO_BUTTON' ):
542
  ?>
inc/CFF_Utils.php CHANGED
@@ -774,8 +774,9 @@ class CFF_Utils{
774
  if( !empty($cff_connected_accounts) ){
775
  $cff_connected_accounts = str_replace('\"','"', $cff_connected_accounts);
776
  $cff_connected_accounts = str_replace("\'","'", $cff_connected_accounts);
777
- $cff_connected_accounts = json_decode( $cff_connected_accounts );
778
- }else{
 
779
  $cff_connected_accounts = [];
780
  }
781
  return $cff_connected_accounts;
774
  if( !empty($cff_connected_accounts) ){
775
  $cff_connected_accounts = str_replace('\"','"', $cff_connected_accounts);
776
  $cff_connected_accounts = str_replace("\'","'", $cff_connected_accounts);
777
+ $cff_connected_accounts = json_decode( $cff_connected_accounts, true );
778
+ }
779
+ if(!is_array($cff_connected_accounts) || $cff_connected_accounts == null){
780
  $cff_connected_accounts = [];
781
  }
782
  return $cff_connected_accounts;
inc/Custom_Facebook_Feed.php CHANGED
@@ -229,6 +229,7 @@ final class Custom_Facebook_Feed{
229
 
230
  $this->cff_ppca_check_notice_dismiss();
231
  $this->register_assets();
 
232
 
233
  if ( $this->cff_blocks->allow_load() ) {
234
  $this->cff_blocks->load();
@@ -253,6 +254,21 @@ final class Custom_Facebook_Feed{
253
  }
254
  }
255
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
 
257
  /**
258
  * Register Assets
@@ -283,7 +299,11 @@ final class Custom_Facebook_Feed{
283
  array(),
284
  CFFVER
285
  );
286
- wp_enqueue_style( 'cff' );
 
 
 
 
287
 
288
  $options = get_option('cff_style_settings');
289
 
@@ -332,8 +352,10 @@ final class Custom_Facebook_Feed{
332
  CFFVER,
333
  true
334
  );
335
- //Enqueue it to load it onto the page
336
- wp_enqueue_script('cffscripts');
 
 
337
  }
338
 
339
 
229
 
230
  $this->cff_ppca_check_notice_dismiss();
231
  $this->register_assets();
232
+ $this->group_posts_process();
233
 
234
  if ( $this->cff_blocks->allow_load() ) {
235
  $this->cff_blocks->load();
254
  }
255
  }
256
 
257
+ /**
258
+ * Launch the Group Posts Cache Process
259
+ *
260
+ *
261
+ * @return void
262
+ * @access public
263
+ */
264
+ function group_posts_process(){
265
+ $cff_cron_schedule = 'hourly';
266
+ $cff_cache_time = get_option( 'cff_cache_time' );
267
+ $cff_cache_time_unit = get_option( 'cff_cache_time_unit' );
268
+ if( $cff_cache_time_unit == 'hours' && $cff_cache_time > 5 ) $cff_cron_schedule = 'twicedaily';
269
+ if( $cff_cache_time_unit == 'days' ) $cff_cron_schedule = 'daily';
270
+ CFF_Group_Posts::group_schedule_event(time(), $cff_cron_schedule);
271
+ }
272
 
273
  /**
274
  * Register Assets
299
  array(),
300
  CFFVER
301
  );
302
+
303
+ $options['cff_enqueue_with_shortcode'] = isset( $options['cff_enqueue_with_shortcode'] ) ? $options['cff_enqueue_with_shortcode'] : false;
304
+ if ( isset( $options['cff_enqueue_with_shortcode'] ) && !$options['cff_enqueue_with_shortcode'] ) {
305
+ wp_enqueue_style( 'cff' );
306
+ }
307
 
308
  $options = get_option('cff_style_settings');
309
 
352
  CFFVER,
353
  true
354
  );
355
+ $options['cff_enqueue_with_shortcode'] = isset( $options['cff_enqueue_with_shortcode'] ) ? $options['cff_enqueue_with_shortcode'] : false;
356
+ if ( isset( $options['cff_enqueue_with_shortcode'] ) && !$options['cff_enqueue_with_shortcode'] ) {
357
+ wp_enqueue_script( 'cffscripts' );
358
+ }
359
  }
360
 
361