resources
4 years ago
AddonsAdminPage.php
4 years ago
AddonsRepository.php
4 years ago
HideSaleBannerRoute.php
4 years ago
RecurringDonationsTab.php
4 years ago
SaleBanners.php
3 years ago
AddonsAdminPage.php
77 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Promotions\InPluginUpsells; |
| 4 | |
| 5 | use Give\Helpers\EnqueueScript; |
| 6 | |
| 7 | /** |
| 8 | * @since 2.17.0 |
| 9 | */ |
| 10 | class AddonsAdminPage |
| 11 | { |
| 12 | protected $containerId = 'give-in-plugin-upsells'; |
| 13 | |
| 14 | /** |
| 15 | * Register menu item |
| 16 | */ |
| 17 | public function register() |
| 18 | { |
| 19 | add_submenu_page( |
| 20 | 'edit.php?post_type=give_forms', |
| 21 | esc_html__('GiveWP Add-ons', 'give'), |
| 22 | esc_html__('Add-ons', 'give'), |
| 23 | 'manage_give_settings', |
| 24 | 'give-add-ons', |
| 25 | [$this, 'render'] |
| 26 | ); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Load scripts |
| 31 | */ |
| 32 | public function loadScripts() |
| 33 | { |
| 34 | $data = array_merge( |
| 35 | (new AddonsRepository())->getAddons(), |
| 36 | [ |
| 37 | 'assetsUrl' => GIVE_PLUGIN_URL . 'assets/dist/', |
| 38 | 'containerId' => $this->containerId, |
| 39 | 'siteUrl' => site_url(), |
| 40 | 'siteName' => get_bloginfo('name'), |
| 41 | ] |
| 42 | ); |
| 43 | |
| 44 | EnqueueScript::make('give-in-plugin-upsells-addons', 'assets/dist/js/admin-upsell-addons-page.js') |
| 45 | ->loadInFooter() |
| 46 | ->registerTranslations() |
| 47 | ->registerLocalizeData('GiveAddons', $data) |
| 48 | ->enqueue(); |
| 49 | |
| 50 | wp_enqueue_style( |
| 51 | 'give-in-plugin-upsells-addons-font', |
| 52 | 'https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap', |
| 53 | [], |
| 54 | null |
| 55 | ); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Render admin page |
| 60 | */ |
| 61 | public function render() |
| 62 | { |
| 63 | echo '<svg style="display: none"><path id="give-in-plugin-upsells-checkmark" d="M5.595 11.373.72 6.498a.75.75 0 0 1 0-1.06l1.06-1.061a.75.75 0 0 1 1.061 0L6.125 7.66 13.159.627a.75.75 0 0 1 1.06 0l1.061 1.06a.75.75 0 0 1 0 1.061l-8.625 8.625a.75.75 0 0 1-1.06 0Z" fill="currentColor"/></svg>'; |
| 64 | echo "<div id=\"{$this->containerId}\"></div>"; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Helper function to determine if current page is Give Add-ons admin page |
| 69 | * |
| 70 | * @return bool |
| 71 | */ |
| 72 | public static function isShowing() |
| 73 | { |
| 74 | return isset($_GET['page']) && $_GET['page'] === 'give-add-ons'; |
| 75 | } |
| 76 | } |
| 77 |