| @@ -2,8 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace Elementor\Modules\Announcements; |
| 4 | 4 | |
| 5 | 5 | use Elementor\Core\Base\App as BaseApp; |
| 6 | +use Elementor\Modules\Ai\Preferences; | |
| 6 | 7 | use Elementor\Modules\Announcements\Classes\Announcement; |
| 7 | 8 | use Elementor\Settings as ElementorSettings; |
| 8 | 9 | |
| 9 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -11,8 +12,10 @@ | ||
| 11 | 12 | } |
| 12 | 13 | |
| 13 | 14 | class Module extends BaseApp { |
| 14 | 15 | |
| 16 | + const AI_ASSETS_BASE_URL = 'https://assets.elementor.com/ai/v1/'; | |
| 17 | + | |
| 15 | 18 | /** |
| 16 | 19 | * @return bool |
| 17 | 20 | */ |
| 18 | 21 | public static function is_active(): bool { |
| @@ -93,10 +96,42 @@ | ||
| 93 | 96 | */ |
| 94 | 97 | private function get_raw_announcements(): array { |
| 95 | 98 | $raw_announcements = []; |
| 96 | 99 | |
| 100 | + if ( Preferences::is_ai_enabled( get_current_user_id() ) ) { | |
| 101 | + $raw_announcements[] = $this->get_ai_announcement_data(); | |
| 102 | + } | |
| 103 | + | |
| 97 | 104 | // DO NOT USE THIS FILTER |
| 98 | 105 | return apply_filters( 'elementor/announcements/raw_announcements', $raw_announcements ); |
| 106 | + } | |
| 107 | + | |
| 108 | + private function get_ai_announcement_data(): array { | |
| 109 | + return [ | |
| 110 | + 'title' => __( 'Discover your new superpowers ', 'elementor' ), | |
| 111 | + 'description' => __( '<p>With AI for text, code, image generation and editing, you can bring your vision to life faster than ever. Start your free trial now - <b>no credit card required!</b></p>', 'elementor' ), | |
| 112 | + 'media' => [ | |
| 113 | + 'type' => 'image', | |
| 114 | + 'src' => self::AI_ASSETS_BASE_URL . 'images/ai-social-hd.gif', | |
| 115 | + ], | |
| 116 | + 'cta' => [ | |
| 117 | + [ | |
| 118 | + 'label' => __( 'Let\'s do it', 'elementor' ), | |
| 119 | + 'variant' => 'primary', | |
| 120 | + 'target' => '_top', | |
| 121 | + 'url' => '#welcome-ai', | |
| 122 | + ], | |
| 123 | + [ | |
| 124 | + 'label' => __( 'Skip', 'elementor' ), | |
| 125 | + 'variant' => 'secondary', | |
| 126 | + ], | |
| 127 | + ], | |
| 128 | + 'triggers' => [ | |
| 129 | + [ | |
| 130 | + 'action' => 'aiStarted', | |
| 131 | + ], | |
| 132 | + ], | |
| 133 | + ]; | |
| 99 | 134 | } |
| 100 | 135 | |
| 101 | 136 | /** |
| 102 | 137 | * Retrieve all announcement objects. |