item
3 weeks ago
credit.php
3 weeks ago
error-message.php
3 weeks ago
header.php
3 weeks ago
index.php
3 weeks ago
likebox.php
3 weeks ago
error-message.php
98 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Custom Facebook Feed : Error Message Template |
| 5 | * Display different error message |
| 6 | * |
| 7 | * @version 2.19 Custom Facebook Feed by Smash Balloon |
| 8 | */ |
| 9 | |
| 10 | // Don't load directly |
| 11 | if (! defined('ABSPATH')) { |
| 12 | die('-1'); |
| 13 | } |
| 14 | use CustomFacebookFeed\CFF_Utils; |
| 15 | use CustomFacebookFeed\CFF_Shortcode_Display; |
| 16 | // Check to see whether this feed will have a PPCA error come Sep 4. If so, display a warning notice. |
| 17 | |
| 18 | $cff_ppca_check_error = CFF_Shortcode_Display::get_error_check($page_id, $user_id, $access_token); |
| 19 | |
| 20 | |
| 21 | // If there's no data then show a pretty error message |
| 22 | if (empty($FBdata->data) || isset($FBdata->cached_error) || $cff_ppca_check_error) : |
| 23 | // Check whether it's an error in the backup cache |
| 24 | if (isset($FBdata->cached_error)) { |
| 25 | $FBdata->error = $FBdata->cached_error; |
| 26 | } |
| 27 | // Show custom message for the PPCA error |
| 28 | if (isset($FBdata->error->message) && strpos($FBdata->error->message, 'Page Public Content Access') !== false) { |
| 29 | $FBdata->error->message = esc_html__('(#10) To use "Page Public Content Access", your use of this endpoint must be reviewed and approved by Facebook.', 'custom-facebook-feed'); |
| 30 | $FBdata->error->type = $FBdata->error->code = $FBdata->error->error_subcode = null; |
| 31 | } |
| 32 | |
| 33 | $cap = CFF_Shortcode_Display::get_error_message_cap(); |
| 34 | $cff_ppca_error = CFF_Shortcode_Display::get_error_check_ppca($FBdata) |
| 35 | |
| 36 | ?> |
| 37 | <div class="cff-error-msg"> |
| 38 | <div> |
| 39 | <i class="fa fa-lock" aria-hidden="true" style="margin-right: 5px;"></i><b><?php echo esc_html__('This message is only visible to admins.', 'custom-facebook-feed'); ?></b><br/> |
| 40 | <?php |
| 41 | if (!$cff_ppca_check_error) { |
| 42 | echo esc_html__('Problem displaying Facebook posts.', 'custom-facebook-feed'); |
| 43 | } |
| 44 | if (isset($FBdata->cached_error)) { |
| 45 | echo esc_html__(' Backup cache in use.', 'custom-facebook-feed'); |
| 46 | } |
| 47 | ?> |
| 48 | <?php if ($cff_ppca_check_error || $cff_ppca_error) : ?> |
| 49 | </div> |
| 50 | <?php if ($cff_ppca_error) : ?> |
| 51 | <b>PPCA Error:</b> <?php echo esc_html__('Due to Facebook API changes it is no longer possible to display a feed from a Facebook Page you are not an admin of. The Facebook feed below is not using a valid Access Token for this Facebook page and so has stopped updating.', 'custom-facebook-feed'); ?> |
| 52 | <?php else : ?> |
| 53 | <a class="cff_notice_dismiss" href="<?php echo esc_url(add_query_arg('cff_ppca_check_notice_dismiss', '0')); ?>"><span class="fa fa-times-circle" aria-hidden="true"></span></a> |
| 54 | <b class="cff-warning-notice">PPCA Error:</b> <?php echo esc_html__('Due to Facebook API changes on September 4, 2020, it will no longer be possible to display a feed from a Facebook Page you are not an admin of. The Facebook feed below is not using a valid Access Token for this Facebook page and so will stop updating after this date.', 'custom-facebook-feed'); ?> |
| 55 | <?php endif; ?> |
| 56 | <?php if (current_user_can($cap)) : ?> |
| 57 | <br /><b style="margin-top: 5px; display: inline-block;"><?php echo esc_html__('Action Required.', 'custom-facebook-feed'); ?>:</b> <?php echo esc_html__('Please', 'custom-facebook-feed'); ?> <a href="https://smashballoon.com/facebook-ppca-error-notice/?utm_campaign=facebook-free&utm_source=error&utm_medium=docs" target="_blank"><?php echo esc_html__('see here', 'custom-facebook-feed'); ?></a> <?php echo esc_html__('for information on how to fix this.', 'custom-facebook-feed'); ?> |
| 58 | <?php endif; ?> |
| 59 | |
| 60 | <?php else : ?> |
| 61 | <br/><a href="javascript:void(0);" id="cff-show-error" onclick="cffShowError()"><?php echo esc_html__('Click to show error', 'custom-facebook-feed'); ?></a> |
| 62 | <script type="text/javascript">function cffShowError() { document.getElementById("cff-error-reason").style.display = "block"; document.getElementById("cff-show-error").style.display = "none"; }</script> |
| 63 | </div> |
| 64 | <div id="cff-error-reason"> |
| 65 | <?php if (isset($FBdata->error->message)) : ?> |
| 66 | <b><?php echo esc_html__('Error', 'custom-facebook-feed'); ?>:</b> <?php echo wp_kses_post($FBdata->error->message); ?> |
| 67 | <?php endif; ?> |
| 68 | <?php if (isset($FBdata->error->type)) : ?> |
| 69 | <b><?php echo esc_html__('Type', 'custom-facebook-feed'); ?>:</b> <?php echo wp_kses_post($FBdata->error->type); ?> |
| 70 | <?php endif; ?> |
| 71 | <?php if (isset($FBdata->error->error_subcode)) : ?> |
| 72 | <b><?php echo esc_html__('Subcode', 'custom-facebook-feed'); ?>:</b> <?php echo wp_kses_post($FBdata->error->error_subcode); ?> |
| 73 | <?php endif; ?> |
| 74 | <?php if (isset($FBdata->error_msg)) : ?> |
| 75 | <b><?php echo esc_html__('Error', 'custom-facebook-feed'); ?>:</b> <?php echo wp_kses_post($FBdata->error_msg); ?> |
| 76 | <?php endif; ?> |
| 77 | <?php if (isset($FBdata->error_code)) : ?> |
| 78 | <?php echo esc_html__('Code', 'custom-facebook-feed'); ?>: <?php echo wp_kses_post($FBdata->error_code); ?> |
| 79 | <?php endif; ?> |
| 80 | <?php if ($FBdata == null) : ?> |
| 81 | <b><?php echo esc_html__('Error', 'custom-facebook-feed'); ?>:</b> <?php echo esc_html__('Server configuration issue', 'custom-facebook-feed'); ?> |
| 82 | <?php endif; ?> |
| 83 | <?php if (empty($FBdata->error) && empty($FBdata->error_msg) && $FBdata !== null) : ?> |
| 84 | <b><?php echo esc_html__('Error', 'custom-facebook-feed'); ?>:</b> <?php echo esc_html__('No posts available for this Facebook ID', 'custom-facebook-feed'); ?> |
| 85 | <?php endif; ?> |
| 86 | <?php if (current_user_can($cap)) : ?> |
| 87 | <br /><b><?php echo esc_html__('Solution', 'custom-facebook-feed'); ?>:</b> <a href="https://smashballoon.com/custom-facebook-feed/docs/errors/?utm_campaign=facebook-free&utm_source=error&utm_medium=docs" target="_blank"><?php echo esc_html__('See here', 'custom-facebook-feed'); ?></a> <?php echo esc_html__('for how to solve this error', 'custom-facebook-feed'); ?> |
| 88 | <?php endif; ?> |
| 89 | |
| 90 | </div> |
| 91 | <?php endif; ?> |
| 92 | <?php if (current_user_can($cap)) : ?> |
| 93 | <style>#cff .cff-error-msg{ display: block !important; }</style> |
| 94 | <?php endif; ?> |
| 95 | |
| 96 | </div> |
| 97 | <?php endif; ?> |
| 98 |