WelcomeBanner.php
57 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Promotions\WelcomeBanner; |
| 4 | |
| 5 | class WelcomeBanner |
| 6 | { |
| 7 | /** |
| 8 | * @since 3.0.0 |
| 9 | */ |
| 10 | public static function isShowing(): bool |
| 11 | { |
| 12 | global $pagenow; |
| 13 | |
| 14 | $option = get_option('givewp_welcome_banner_dismiss'); |
| 15 | |
| 16 | return $pagenow === 'plugins.php' && !$option; |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * @since 3.0.0 |
| 21 | */ |
| 22 | public function render(): void |
| 23 | { |
| 24 | echo '<div id="givewp-welcome-banner"></div>'; |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * @since 3.0.0 |
| 29 | */ |
| 30 | public function loadScripts(): void |
| 31 | { |
| 32 | wp_enqueue_script( |
| 33 | 'givewp-welcome-banner', |
| 34 | GIVE_PLUGIN_URL . 'assets/dist/js/welcome-banner.js', |
| 35 | [], |
| 36 | GIVE_VERSION, |
| 37 | true |
| 38 | ); |
| 39 | |
| 40 | wp_localize_script( |
| 41 | 'givewp-welcome-banner', |
| 42 | 'WelcomeBanner', |
| 43 | [ |
| 44 | 'root' => esc_url_raw(rest_url('give-api/v2/welcome-banner')), |
| 45 | 'nonce' => wp_create_nonce('wp_rest'), |
| 46 | 'action' => 'givewp_welcome_banner_dismiss', |
| 47 | 'assets' => GIVE_PLUGIN_URL . 'assets/dist/images/admin/promotions/welcome-banner', |
| 48 | ] |
| 49 | ); |
| 50 | |
| 51 | wp_set_script_translations( 'givewp-welcome-banner', 'give' ); |
| 52 | |
| 53 | wp_enqueue_style('givewp-design-system-foundation'); |
| 54 | wp_enqueue_style('givewp-admin-fonts'); |
| 55 | } |
| 56 | } |
| 57 |