Blocks
2 weeks ago
Traits
2 weeks ago
CFF_About_Us.php
2 weeks ago
CFF_Admin.php
2 weeks ago
CFF_Admin_Notices.php
2 weeks ago
CFF_Callout.php
2 weeks ago
CFF_Global_Settings.php
2 weeks ago
CFF_Install_Skin.php
2 weeks ago
CFF_New_User.php
2 weeks ago
CFF_Notifications.php
2 weeks ago
CFF_Onboarding_Wizard.php
2 weeks ago
CFF_Support.php
2 weeks ago
CFF_Support_Tool.php
2 weeks ago
CFF_Upgrader.php
2 weeks ago
CFF_oEmbeds.php
2 weeks ago
index.php
2 weeks ago
CFF_Admin_Notices.php
107 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * CFF Admin Notices. |
| 5 | * |
| 6 | * @since 4.0 |
| 7 | */ |
| 8 | |
| 9 | namespace CustomFacebookFeed\Admin; |
| 10 | |
| 11 | use CustomFacebookFeed\Builder\CFF_Source; |
| 12 | |
| 13 | if (!defined('ABSPATH')) { |
| 14 | exit; // Exit if accessed directly |
| 15 | } |
| 16 | |
| 17 | class CFF_Admin_Notices |
| 18 | { |
| 19 | public function __construct() |
| 20 | { |
| 21 | $this->init(); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Determining if the user is viewing the our page, if so, party on. |
| 26 | * |
| 27 | * @since 4.0 |
| 28 | */ |
| 29 | public function init() |
| 30 | { |
| 31 | if (!is_admin()) { |
| 32 | return; |
| 33 | } |
| 34 | add_action('cff_admin_notices', [$this, 'cff_group_deprecation_dismiss_notice']); |
| 35 | add_action('admin_notices', [$this, 'cff_group_deprecation_dismiss_notice']); |
| 36 | add_action('wp_ajax_cff_review_notice_dismiss', [ $this, 'cff_review_notice_dismiss' ]); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Group Deprecation Notice |
| 41 | * |
| 42 | * @since 4.0.2/4.0.7 |
| 43 | */ |
| 44 | public function cff_group_deprecation_dismiss_notice() |
| 45 | { |
| 46 | $cff_statuses_option = get_option('cff_statuses', array()); |
| 47 | if (!empty($cff_statuses_option['cff_group_deprecation_dismiss']) && $cff_statuses_option['cff_group_deprecation_dismiss'] !== true) { |
| 48 | return; |
| 49 | } |
| 50 | |
| 51 | if (!empty($_GET['cff_dismiss_notice']) && $_GET['cff_dismiss_notice'] === 'group_deprecation') { |
| 52 | \cff_main()->cff_error_reporter->dismiss_group_deprecation_error(); |
| 53 | $cff_statuses_option['cff_group_deprecation_dismiss'] = true; |
| 54 | update_option('cff_statuses', $cff_statuses_option, false); |
| 55 | return; |
| 56 | } |
| 57 | |
| 58 | if (!CFF_Source::should_show_group_deprecation()) { |
| 59 | return; |
| 60 | } |
| 61 | $close_href = add_query_arg(array('cff_dismiss_notice' => 'group_deprecation')); |
| 62 | $group_doc_url = 'https://smashballoon.com/doc/facebook-api-changes-affecting-groups-april-2024/?utm_campaign=facebook-free&utm_source=settings&utm_medium=docs'; |
| 63 | ?> |
| 64 | <div class="notice notice-error is-dismissible cff-dismissible"> |
| 65 | <p> |
| 66 | <?php |
| 67 | echo |
| 68 | sprintf( |
| 69 | __('Due to changes with the Facebook API, which we use to create feeds, group feeds will no longer update after April of 2024 %sLearn More %s', 'custom-facebook-feed'), |
| 70 | '<a href="' . esc_url($group_doc_url) . '">', |
| 71 | '</a>' |
| 72 | ); |
| 73 | ?> |
| 74 | <a href="<?php echo esc_attr($close_href); ?>"> |
| 75 | <?php echo __('Dismiss', 'custom-facebook-feed'); ?> |
| 76 | </a> |
| 77 | </p> |
| 78 | </div> |
| 79 | <?php |
| 80 | } |
| 81 | public function cff_review_notice_dismiss() |
| 82 | { |
| 83 | check_ajax_referer('cff_nonce', 'cff_nonce'); |
| 84 | |
| 85 | $cap = current_user_can('manage_custom_facebook_feed_options') ? 'manage_custom_facebook_feed_options' : 'manage_options'; |
| 86 | $cap = apply_filters('cff_settings_pages_capability', $cap); |
| 87 | if (! current_user_can($cap)) { |
| 88 | wp_send_json_error(); // This auto-dies. |
| 89 | } |
| 90 | |
| 91 | $this->cff_review_notice_dismiss_action(); |
| 92 | wp_send_json_success(); |
| 93 | } |
| 94 | |
| 95 | public function cff_review_notice_dismiss_action($action = 1) |
| 96 | { |
| 97 | if (intval($action) === 1) { |
| 98 | update_option('cff_rating_notice', 'dismissed', false); |
| 99 | $statuses = get_option('cff_statuses', []); |
| 100 | $statuses['rating_notice_dismissed'] = cff_get_current_time(); |
| 101 | update_option('cff_statuses', $statuses); |
| 102 | } elseif (strtolower($action) === 'later') { |
| 103 | set_transient('custom_facebook_rating_notice_waiting', 'waiting', 2 * WEEK_IN_SECONDS); |
| 104 | update_option('cff_rating_notice', 'pending', false); |
| 105 | } |
| 106 | } |
| 107 | } |