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
4 years ago
ServiceProvider.php
4 years ago
AddonsAdminPage.php
79 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\InPluginUpsells; |
| 4 | |
| 5 | /** |
| 6 | * @since 2.17.0 |
| 7 | */ |
| 8 | class AddonsAdminPage |
| 9 | { |
| 10 | protected $containerId = 'give-in-plugin-upsells'; |
| 11 | |
| 12 | /** |
| 13 | * Register menu item |
| 14 | */ |
| 15 | public function register() |
| 16 | { |
| 17 | add_submenu_page( |
| 18 | 'edit.php?post_type=give_forms', |
| 19 | esc_html__('GiveWP Add-ons', 'give'), |
| 20 | esc_html__('Add-ons', 'give'), |
| 21 | 'manage_give_settings', |
| 22 | 'give-add-ons', |
| 23 | [$this, 'render'] |
| 24 | ); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Load scripts |
| 29 | */ |
| 30 | public function loadScripts() |
| 31 | { |
| 32 | wp_enqueue_script( |
| 33 | 'give-in-plugin-upsells-addons', |
| 34 | GIVE_PLUGIN_URL . 'assets/dist/js/admin-upsell-addons-page.js', |
| 35 | ['wp-element', 'wp-i18n', 'wp-hooks'], |
| 36 | GIVE_VERSION, |
| 37 | true |
| 38 | ); |
| 39 | |
| 40 | wp_enqueue_style( |
| 41 | 'give-in-plugin-upsells-addons-font', |
| 42 | 'https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap', |
| 43 | [], |
| 44 | null |
| 45 | ); |
| 46 | |
| 47 | wp_localize_script( |
| 48 | 'give-in-plugin-upsells-addons', |
| 49 | 'GiveAddons', |
| 50 | array_merge( |
| 51 | (new AddonsRepository())->getAddons(), |
| 52 | [ |
| 53 | 'assetsUrl' => GIVE_PLUGIN_URL . 'assets/dist/', |
| 54 | 'containerId' => $this->containerId, |
| 55 | ] |
| 56 | ) |
| 57 | ); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Render admin page |
| 62 | */ |
| 63 | public function render() |
| 64 | { |
| 65 | 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>'; |
| 66 | echo "<div id=\"{$this->containerId}\"></div>"; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Helper function to determine if current page is Give Add-ons admin page |
| 71 | * |
| 72 | * @return bool |
| 73 | */ |
| 74 | public static function isShowing() |
| 75 | { |
| 76 | return isset($_GET['page']) && $_GET['page'] === 'give-add-ons'; |
| 77 | } |
| 78 | } |
| 79 |