Endpoints
2 years ago
resources
2 years ago
AddonsAdminPage.php
3 years ago
AddonsRepository.php
4 years ago
LegacyFormEditor.php
2 years ago
PaymentGateways.php
3 years ago
SaleBanners.php
1 year ago
PaymentGateways.php
64 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Promotions\InPluginUpsells; |
| 4 | |
| 5 | use Give\Helpers\EnqueueScript; |
| 6 | use Give\Helpers\Utils; |
| 7 | |
| 8 | class PaymentGateways |
| 9 | { |
| 10 | |
| 11 | /** |
| 12 | * Load scripts |
| 13 | * |
| 14 | * @since 2.27.1 |
| 15 | */ |
| 16 | public function loadScripts() |
| 17 | { |
| 18 | $data = [ |
| 19 | 'apiRoot' => esc_url_raw(rest_url('give-api/v2')), |
| 20 | 'apiNonce' => wp_create_nonce('wp_rest'), |
| 21 | ]; |
| 22 | |
| 23 | EnqueueScript::make( |
| 24 | 'give-in-plugin-upsells-payment-gateway', |
| 25 | 'assets/dist/js/payment-gateway.js' |
| 26 | ) |
| 27 | ->loadInFooter() |
| 28 | ->registerTranslations() |
| 29 | ->registerLocalizeData('GiveSettings', $data) |
| 30 | ->enqueue(); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * |
| 35 | * @since 2.27.1 |
| 36 | * |
| 37 | */ |
| 38 | public function renderPaymentGatewayRecommendation() |
| 39 | { |
| 40 | $isDismissed = get_option('givewp_payment_gateway_fee_recovery_recommendation', false); |
| 41 | $feeRecoveryIsActive = Utils::isPluginActive('give-fee-recovery/give-fee-recovery.php'); |
| 42 | |
| 43 | if ($feeRecoveryIsActive | $isDismissed) { |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | require_once GIVE_PLUGIN_DIR . 'src/Promotions/InPluginUpsells/resources/views/payment-gateway.php'; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * |
| 52 | * @since 2.27.1 |
| 53 | * |
| 54 | */ |
| 55 | public static function isShowing(): bool |
| 56 | { |
| 57 | $isGatewaysTab = isset($_GET['tab']) && $_GET['tab'] === 'gateways'; |
| 58 | $isGiveFormsPostType = isset($_GET['post_type']) && $_GET['post_type'] === 'give_forms'; |
| 59 | |
| 60 | return $isGiveFormsPostType && $isGatewaysTab; |
| 61 | } |
| 62 | |
| 63 | } |
| 64 |