Endpoints
3 years ago
resources
2 years ago
AddonsAdminPage.php
3 years ago
AddonsRepository.php
4 years ago
LegacyFormEditor.php
3 years ago
PaymentGateways.php
3 years ago
SaleBanners.php
3 years ago
SummerSalesBanner.php
2 years ago
LegacyFormEditor.php
66 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Promotions\InPluginUpsells; |
| 4 | |
| 5 | use Give\Helpers\EnqueueScript; |
| 6 | use Give\Helpers\Utils; |
| 7 | |
| 8 | class LegacyFormEditor |
| 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-legacy-form-editor', |
| 25 | 'assets/dist/js/donation-options.js' |
| 26 | ) |
| 27 | ->loadInFooter() |
| 28 | ->registerTranslations() |
| 29 | ->registerLocalizeData('GiveLegacyFormEditor', $data) |
| 30 | ->enqueue(); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * |
| 35 | * @since 2.27.1 |
| 36 | * |
| 37 | */ |
| 38 | public function renderDonationOptionsRecurringRecommendation() |
| 39 | { |
| 40 | $isDismissed = get_option('givewp_form_editor_donation_options_recurring_recommendation', false); |
| 41 | $recurringAddonIsActive = Utils::isPluginActive('give-recurring/give-recurring.php'); |
| 42 | |
| 43 | if ($recurringAddonIsActive | $isDismissed) { |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | require_once GIVE_PLUGIN_DIR . 'src/Promotions/InPluginUpsells/resources/views/donation-options-form-editor.php'; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * |
| 52 | * @since 2.27.1 |
| 53 | * |
| 54 | */ |
| 55 | public static function isShowing(): bool |
| 56 | { |
| 57 | $queryParameters = $_GET; |
| 58 | |
| 59 | if (isset($queryParameters['action']) && $queryParameters['action'] === 'edit' && $queryParameters['post']) { |
| 60 | return true; |
| 61 | } |
| 62 | |
| 63 | return false; |
| 64 | } |
| 65 | } |
| 66 |