| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Modules\Registerer; |
| 4 |
|
| 5 |
defined('ABSPATH') or die; |
| 6 |
|
| 7 |
use FluentForm\App\Helpers\Helper; |
| 8 |
use FluentForm\App\Http\Controllers\AdminNoticeController; |
| 9 |
|
| 10 |
class StripeKeyNotice |
| 11 |
{ |
| 12 |
public static function register() |
| 13 |
{ |
| 14 |
if (static::shouldRegister()) { |
| 15 |
add_action('fluentform/global_menu', [static::class, 'show'], 99); |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
protected static function shouldRegister() |
| 20 |
{ |
| 21 |
if (!Helper::isFluentAdminPage() || wp_doing_ajax()) { |
| 22 |
return false; |
| 23 |
} |
| 24 |
|
| 25 |
return get_option('fluentform_stripe_key_decrypt_failed') === 'yes'; |
| 26 |
} |
| 27 |
|
| 28 |
public static function show() |
| 29 |
{ |
| 30 |
$notice = new AdminNoticeController(); |
| 31 |
$notice->addNotice(self::getMessage()); |
| 32 |
$notice->showNotice(); |
| 33 |
} |
| 34 |
|
| 35 |
private static function getMessage() |
| 36 |
{ |
| 37 |
$message = __( |
| 38 |
'Fluent Forms could not read your saved Stripe keys. This can happen after a hosting or security change that rotates WordPress security keys. Please re-enter your Stripe keys to keep accepting payments.', |
| 39 |
'fluentform' |
| 40 |
); |
| 41 |
|
| 42 |
return [ |
| 43 |
'name' => 'stripe_key_decrypt_failed', |
| 44 |
'title' => '', |
| 45 |
'message' => $message, |
| 46 |
'links' => [ |
| 47 |
[ |
| 48 |
'href' => admin_url('admin.php?page=fluent_forms_settings#payments/payment_methods'), |
| 49 |
'btn_text' => __('Fix Stripe Keys', 'fluentform'), |
| 50 |
'btn_atts' => 'class="mr-1 el-button--success el-button--mini"', |
| 51 |
], |
| 52 |
[ |
| 53 |
'href' => admin_url('admin.php?page=fluent_forms'), |
| 54 |
'btn_text' => __('Dismiss', 'fluentform'), |
| 55 |
'btn_atts' => 'class="text-button el-button--mini ff_nag_cross" data-notice_type="temp" data-notice_name="stripe_key_decrypt_failed"', |
| 56 |
], |
| 57 |
], |
| 58 |
]; |
| 59 |
} |
| 60 |
} |
| 61 |
|