PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 4.6.0
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v4.6.0
4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / EmbedPress / MilestoneNotification.php
embedpress / EmbedPress Last commit date
AMP 3 years ago Analytics 1 month ago Elementor 3 days ago Ends 3 days ago Gutenberg 3 days ago Includes 3 days ago Plugins 1 year ago Providers 1 month ago ThirdParty 3 days ago AutoLoader.php 3 years ago Compatibility.php 3 years ago Core.php 3 days ago CoreLegacy.php 2 months ago DisablerLegacy.php 3 years ago Loader.php 3 years ago MilestoneNotification.php 3 days ago RestAPI.php 1 month ago Shortcode.php 3 days ago index.html 7 years ago simple_html_dom.php 4 years ago
MilestoneNotification.php
548 lines
1 <?php
2
3 /**
4 * Milestone Notification for WordPress Admin Dashboard
5 *
6 * Displays a beautiful animated notification on the main WordPress dashboard (/wp-admin/)
7 * showing milestone achievements and encouraging premium upgrades.
8 *
9 * Features:
10 * - Automatically appears on dashboard after 2 seconds
11 * - Slides in from bottom-right with smooth animation
12 * - Fully responsive design
13 * - Close on button click, overlay click, or Escape key
14 * - Customizable milestone data and stats
15 *
16 * Usage:
17 * - Automatically initialized in embedpress.php
18 * - Only loads on WordPress dashboard (index.php)
19 * - Customize data in get_milestone_data() method
20 * - Control display logic in should_show_milestone() method
21 *
22 * @package EmbedPress
23 * @author EmbedPress <help@embedpress.com>
24 * @copyright Copyright (C) 2023 WPDeveloper. All rights reserved.
25 * @license GPLv3 or later
26 * @since 1.0.0
27 */
28
29 namespace EmbedPress;
30
31 defined('ABSPATH') or die("No direct script access allowed.");
32
33 class MilestoneNotification
34 {
35 /**
36 * Initialize the milestone notification
37 */
38 public static function init()
39 {
40 $instance = new self();
41
42 // Hook into admin footer to inject the notification
43 add_action('admin_footer', [$instance, 'render_milestone_notification']);
44
45 // Enqueue styles and scripts
46 add_action('admin_enqueue_scripts', [$instance, 'enqueue_assets']);
47
48 // AJAX handler to mark milestone as seen
49 add_action('wp_ajax_embedpress_mark_milestone_seen', [$instance, 'ajax_mark_milestone_seen']);
50 }
51
52 /**
53 * Enqueue CSS and JS for milestone notification
54 */
55 public function enqueue_assets($hook)
56 {
57 // Only load on main dashboard page
58 if ($hook !== 'index.php') {
59 return;
60 }
61
62 // Never show two EmbedPress announcements at once: when the "What's
63 // New" feature-preview modal is queued for this release it owns the
64 // dashboard, so suppress the milestone entirely (assets + markup).
65 if ($this->whatsnew_modal_active()) {
66 return;
67 }
68
69 // Enqueue the milestone CSS
70 wp_enqueue_style(
71 'embedpress-milestone',
72 EMBEDPRESS_PLUGIN_DIR_URL . 'assets/css/admin.build.css',
73 [],
74 EMBEDPRESS_VERSION
75 );
76
77 // Enqueue inline script for milestone functionality
78 wp_add_inline_script('jquery', $this->get_milestone_script());
79 }
80
81 /**
82 * Get the JavaScript for milestone functionality
83 */
84 private function get_milestone_script()
85 {
86 return "
87 jQuery(document).ready(function($) {
88 // Auto-show milestone after 2 seconds
89 setTimeout(function() {
90 showEmbedPressMilestone();
91 }, 2000);
92 });
93
94 function showEmbedPressMilestone() {
95 var container = document.getElementById('embedpress-milestone-container');
96 if (!container) return;
97
98 container.style.display = 'block';
99
100 // Trigger animation
101 setTimeout(function() {
102 var overlay = container.querySelector('.milestone-overlay');
103 var notification = container.querySelector('.milestone-notification');
104
105 if (overlay) overlay.classList.add('milestone-overlay--visible');
106 if (notification) notification.classList.add('milestone-notification--visible');
107 }, 100);
108 }
109
110 function hideEmbedPressMilestone(event) {
111 if (event) event.preventDefault();
112
113 var container = document.getElementById('embedpress-milestone-container');
114 if (!container) return;
115
116 var overlay = container.querySelector('.milestone-overlay');
117 var notification = container.querySelector('.milestone-notification');
118
119 if (overlay) overlay.classList.remove('milestone-overlay--visible');
120 if (notification) notification.classList.remove('milestone-notification--visible');
121
122 // Remove from DOM after animation
123 setTimeout(function() {
124 container.style.display = 'none';
125 }, 400);
126
127 // Mark milestone as seen via AJAX
128 jQuery.post(ajaxurl, {
129 action: 'embedpress_mark_milestone_seen',
130 nonce: '" . wp_create_nonce('embedpress_milestone_nonce') . "'
131 });
132 }
133 ";
134 }
135
136 /**
137 * Render the milestone notification HTML
138 */
139 public function render_milestone_notification()
140 {
141 // Only show on main dashboard
142 $screen = get_current_screen();
143 if (!$screen || $screen->id !== 'dashboard') {
144 return;
145 }
146
147 // Never show two EmbedPress announcements at once: the "What's New"
148 // feature-preview modal takes precedence on the dashboard, so bail if
149 // it's queued for this release (mirrors FeatureNoticeManager's tooltip
150 // suppression).
151 if ($this->whatsnew_modal_active()) {
152 return;
153 }
154
155 // Check if milestone should be shown
156 if (!$this->should_show_milestone()) {
157 return;
158 }
159
160 // Get milestone data
161 $data = $this->get_milestone_data();
162
163 // Check if Black Friday banner should be shown (until December 4, 2025)
164 $show_bfriday_banner = (time() < strtotime('2025-12-04 23:59:59'));
165
166 ?>
167 <div id="embedpress-milestone-container" style="display: none;">
168 <div class="milestone-overlay">
169 <div class="milestone-notification" onclick="event.stopPropagation()">
170 <!-- Header -->
171 <div class="milestone-header">
172 <h2 class="milestone-title"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 91.226 91.226">
173 <g transform="translate(0 0)">
174 <path d="M187.4,174.9v12.5H174.9V192.5h17.6V174.9Z" transform="translate(-101.271 -101.271)" fill="#25396F"></path>
175 <path d="M88.255,38.749A22.6,22.6,0,0,0,71.163,27.383,22.279,22.279,0,0,0,58.912,29.4c-.421.21-.884.421-1.305.674A22.538,22.538,0,0,0,46.915,43.338h0L34.622,78.405a12.808,12.808,0,0,1-5.767,7.241c-.21.126-.463.253-.716.379A12.309,12.309,0,0,1,21.53,87.12a12.181,12.181,0,0,1-9.177-6.1A12.027,12.027,0,0,1,11.3,71.838a12.16,12.16,0,0,1,5.767-7.283c.253-.126.463-.253.716-.379a12.243,12.243,0,0,1,6.609-1.095c.084,0,.168.042.253.042l-2.526,7.367a.955.955,0,0,0,.589,1.221l6.525,2.1a.91.91,0,0,0,1.179-.589l5.641-16.039a1.536,1.536,0,0,0-.084-1.221,1.445,1.445,0,0,0-.968-.8l-5.936-1.726a1.5,1.5,0,0,0-.421-.084l-.547-.168v.042c-.842-.21-1.684-.337-2.526-.463a22.488,22.488,0,0,0-12.293,2.021c-.463.21-.884.463-1.305.674A22.524,22.524,0,0,0,1.2,69.017,22.242,22.242,0,0,0,3.175,86.109,22.6,22.6,0,0,0,20.267,97.476a22.279,22.279,0,0,0,12.25-2.021c.421-.21.884-.421,1.305-.674A22.417,22.417,0,0,0,44.473,81.563h0L56.85,46.5v-.126c1.389-3.536,3.157-5.767,5.725-7.2.21-.126.463-.253.716-.379A12.309,12.309,0,0,1,69.9,37.7a12.069,12.069,0,0,1,4.462,22.564c-.253.126-.463.253-.716.379A12.393,12.393,0,0,1,67,61.735a11.96,11.96,0,0,1-2.063-.421h-.084l-3.789-1.137a.756.756,0,0,0-.968.505L57.144,69.06a.8.8,0,0,0,.547,1.052l4.673,1.347a20,20,0,0,0,3.452.674,22.342,22.342,0,0,0,12.25-2.021h.042c.463-.21.884-.463,1.347-.674A22.671,22.671,0,0,0,88.255,38.749Z" transform="translate(-0.186 -15.764)" fill="#25396F"></path>
176 <path d="M0,0V17.6H5.094V5.094H17.555V0Z" fill="#25396F"></path>
177 </g>
178 </svg> EmbedPress Milestone</h2>
179 <button class="milestone-close" onclick="hideEmbedPressMilestone(event)" aria-label="Close">
180 <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
181 <path d="M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z" fill="currentColor" />
182 </svg>
183 </button>
184 </div>
185
186 <?php if ($show_bfriday_banner): ?>
187 <div class="bfriday-deal-campaign">
188 <a href="https://embedpress.com/in/bfcm2025-unlock-advanced-analytics" target="_blank">
189 <img src="<?php echo esc_url(EMBEDPRESS_URL_ASSETS . 'images/bfcm2025-banner.png'); ?>" alt="Black Friday Sale">
190 </a>
191 </div>
192 <?php endif; ?>
193
194 <!-- Content -->
195 <div class="milestone-content">
196 <!-- Achievement Banner -->
197 <div class="milestone-achievement">
198 <h3 class="milestone-achievement-title">
199 <?php echo $data['emoji']; ?> <?php echo wp_kses_post($data['title']); ?>
200 </h3>
201 <p class="milestone-achievement-subtitle">
202 <?php echo wp_kses_post($data['subtitle']); ?>
203 </p>
204 <a href="<?php echo esc_url(admin_url('admin.php?page=embedpress-analytics')); ?>" class="milestone-link">
205 View Analytics
206 </a>
207 </div>
208
209 <!-- Stats Grid -->
210 <div class="milestone-stats">
211 <div class="milestone-stats-inner-wrapper">
212
213 <div class="milestone-stats-inner">
214 <?php foreach ($data['stats'] as $stat) : ?>
215 <div class="milestone-stat-card">
216 <div class="milestone-stat-label"><?php echo esc_html($stat['label']); ?></div>
217 <div class="milestone-stat-value"><?php echo esc_html($stat['value']); ?></div>
218 </div>
219 <?php endforeach; ?>
220 </div>
221
222 <!-- CTA Button -->
223 <a href="<?php echo esc_url('https://embedpress.com/in/unlock-advanced-analytics'); ?>" target="_blank" class="milestone-cta">
224 Unlock Pro Insights
225 </a>
226 </div>
227
228
229 </div>
230 </div>
231 </div>
232 </div>
233 </div>
234 <?php
235 }
236
237 /**
238 * Get milestone data
239 * Fetches real analytics data from the database to show user's embed performance
240 */
241 private function get_milestone_data()
242 {
243 // Get Analytics Manager instance
244 $analytics_manager = \EmbedPress\Includes\Classes\Analytics\Analytics_Manager::get_instance();
245
246 // Get real analytics data
247 $total_embeds = 0;
248 $total_views = 0;
249 $total_unique_viewers = 0;
250 $total_impressions = 0;
251
252 try {
253 // Get content count by type
254 $content_by_type = $analytics_manager->get_total_content_by_type();
255 $total_embeds = isset($content_by_type['total']) ? $content_by_type['total'] : 0;
256
257 // Get total views, impressions, and unique viewers from Data_Collector
258 $data_collector = new \EmbedPress\Includes\Classes\Analytics\Data_Collector();
259 $total_views = $data_collector->get_total_views();
260 $total_impressions = $data_collector->get_total_impressions();
261 $total_unique_viewers = $data_collector->get_total_unique_viewers();
262 } catch (\Exception $e) {
263 // Fallback to default values if there's an error
264 error_log('EmbedPress Milestone: Error fetching analytics data - ' . $e->getMessage());
265 }
266
267 // Format numbers for display
268 $embeds_formatted = $this->format_number($total_embeds);
269 $views_formatted = $this->format_number($total_views);
270 $unique_views_formatted = $this->format_number($total_unique_viewers);
271 $impressions_formatted = $this->format_number($total_impressions);
272
273 // Calculate total interactions (sum of all metrics)
274 $total_interactions = $total_embeds + $total_views + $total_unique_viewers + $total_impressions;
275
276 // Get milestone configuration based on total interactions
277 $milestone_config = $this->get_milestone_config($total_interactions);
278
279 return array_merge($milestone_config, [
280 'stats' => [
281 [
282 'label' => 'Total Embeds',
283 'value' => $embeds_formatted
284 ],
285 [
286 'label' => 'Total Views',
287 'value' => $views_formatted
288 ],
289 [
290 'label' => 'Unique Views',
291 'value' => $unique_views_formatted
292 ],
293 [
294 'label' => 'Total Impressions',
295 'value' => $impressions_formatted
296 ]
297 ]
298 ]);
299 }
300
301 /**
302 * Get milestone configuration based on total interactions
303 * Returns unique title, subtitle, and emoji for each milestone level
304 */
305 private function get_milestone_config($total_interactions)
306 {
307 // Define milestone levels with unique messages
308 $milestones = [
309 1000000 => [
310 'emoji' => '👑',
311 'title' => 'Legendary! <strong>1M+ interactions achieved!</strong>',
312 'subtitle' => 'You\'re an <strong>absolute legend</strong>! Your embeds are reaching millions. Pro analytics will help you scale to infinity.',
313 'level' => '1m'
314 ],
315 500000 => [
316 'emoji' => '💎',
317 'title' => 'Diamond Status! <strong>500K+ interactions!</strong>',
318 'subtitle' => 'You\'ve reached <strong>diamond tier</strong>! Your content is viral. Unlock Pro to maximize your massive reach.',
319 'level' => '500k'
320 ],
321 250000 => [
322 'emoji' => '🏆',
323 'title' => 'Champion! <strong>250K+ interactions unlocked!</strong>',
324 'subtitle' => 'You\'re a <strong>true champion</strong>! Your embeds are crushing it. Get Pro insights to dominate even more.',
325 'level' => '250k'
326 ],
327 100000 => [
328 'emoji' => '🌟',
329 'title' => 'Superstar! <strong>100K+ interactions reached!</strong>',
330 'subtitle' => 'You\'re a <strong>superstar</strong>! Your content is exploding. Upgrade to Pro for enterprise-level analytics.',
331 'level' => '100k'
332 ],
333 50000 => [
334 'emoji' => '',
335 'title' => 'Incredible! <strong>50K+ interactions achieved!</strong>',
336 'subtitle' => 'You\'re a <strong>Pro</strong>! Unlock advanced analytics to scale even further and dominate your niche.',
337 'level' => '50k'
338 ],
339 20000 => [
340 'emoji' => '🔥',
341 'title' => 'Amazing! <strong>20K+ interactions and counting!</strong>',
342 'subtitle' => 'Your embeds are <strong>on fire</strong>! Get Pro to unlock powerful insights and boost performance.',
343 'level' => '20k'
344 ],
345 10000 => [
346 'emoji' => '',
347 'title' => 'Fantastic! You\'ve reached <strong>10K</strong> interactions!',
348 'subtitle' => 'You\'re doing <strong>great</strong>! Upgrade to Pro to see detailed analytics and grow even faster.',
349 'level' => '10k'
350 ],
351 5000 => [
352 'emoji' => '🎯',
353 'title' => 'Awesome! <strong>5K interactions milestone unlocked!</strong>',
354 'subtitle' => 'Your content is <strong>resonating</strong>! Unlock Pro to discover what\'s working best.',
355 'level' => '5k'
356 ],
357 1000 => [
358 'emoji' => '🎉',
359 'title' => 'Congratulations! <strong>1K+ interactions reached!</strong>',
360 'subtitle' => 'Your embeds are <strong>gaining traction</strong>! Upgrade to Pro to see advanced analytics and improve performance.',
361 'level' => '1k'
362 ]
363 ];
364
365 // Find the appropriate milestone level
366 foreach ($milestones as $threshold => $config) {
367 if ($total_interactions >= $threshold) {
368 return $config;
369 }
370 }
371
372 // Default for users below 1K interactions
373 return [
374 'emoji' => '👋',
375 'title' => 'Welcome! Your <strong>embed journey</strong> has begun!',
376 'subtitle' => 'Start measuring your embed performance today. Gain deeper insights, monitor engagement, and level up with EmbedPress Pro.',
377 'level' => 'starter'
378 ];
379 }
380
381 /**
382 * Format number for display (e.g., 1000 -> 1K, 1000000 -> 1M)
383 *
384 * @param int $number
385 * @return string
386 */
387 private function format_number($number)
388 {
389 $number = (int) $number;
390
391 if ($number === 0) {
392 return '0';
393 }
394
395 if ($number >= 1000000) {
396 return round($number / 1000000, 1) . 'M';
397 }
398
399 if ($number >= 1000) {
400 return round($number / 1000, 1) . 'K';
401 }
402
403 return (string) $number;
404 }
405
406 /**
407 * Check if milestone should be shown
408 * Shows milestone when:
409 * 1. Site reaches a new milestone level
410 */
411 private function should_show_milestone()
412 {
413 // Check if milestone is disabled in settings
414 $g_settings = get_option(EMBEDPRESS_PLG_NAME);
415 $turn_off_milestone = isset($g_settings['turn_off_milestone']) ? intval($g_settings['turn_off_milestone']) : 0;
416 if (!$turn_off_milestone) {
417 return false;
418 }
419
420 // Check if Pro is active - don't show milestone for Pro users
421 $license_info = \EmbedPress\Includes\Classes\Helper::get_license_info();
422 if ($license_info['is_pro_active']) {
423 return false;
424 }
425
426 // Get Analytics Manager instance
427 $analytics_manager = \EmbedPress\Includes\Classes\Analytics\Analytics_Manager::get_instance();
428
429 // Get real analytics data
430 $total_embeds = 0;
431 $total_views = 0;
432 $total_unique_viewers = 0;
433 $total_impressions = 0;
434
435 try {
436 // Get content count by type
437 $content_by_type = $analytics_manager->get_total_content_by_type();
438 $total_embeds = isset($content_by_type['total']) ? $content_by_type['total'] : 0;
439
440 // Get total views, impressions, and unique viewers from Data_Collector
441 $data_collector = new \EmbedPress\Includes\Classes\Analytics\Data_Collector();
442 $total_views = $data_collector->get_total_views();
443 $total_impressions = $data_collector->get_total_impressions();
444 $total_unique_viewers = $data_collector->get_total_unique_viewers();
445 } catch (\Exception $e) {
446 error_log('EmbedPress Milestone: Error fetching analytics data - ' . $e->getMessage());
447 return false;
448 }
449
450 // Calculate total interactions
451 $total_interactions = $total_embeds + $total_views + $total_unique_viewers + $total_impressions;
452
453 // Determine current milestone level
454 $current_level = 'starter';
455 if ($total_interactions >= 50000) {
456 $current_level = '50k';
457 } elseif ($total_interactions >= 20000) {
458 $current_level = '20k';
459 } elseif ($total_interactions >= 10000) {
460 $current_level = '10k';
461 } elseif ($total_interactions >= 5000) {
462 $current_level = '5k';
463 } elseif ($total_interactions >= 1000) {
464 $current_level = '1k';
465 }
466
467 // Get the last seen milestone level (site-wide option)
468 $last_seen_level = get_option('embedpress_milestone_level', '');
469
470 // Show milestone if:
471 // 1. Site has never seen any milestone, OR
472 // 2. Site has reached a new milestone level
473 if (empty($last_seen_level) || $last_seen_level !== $current_level) {
474 // Check if this milestone is already showing (not yet dismissed)
475 $is_showing = get_option('is_embedpress_milestone_showing', false);
476 if ($is_showing) {
477 return true; // Still showing, don't reset
478 }
479
480 // Don't update here - only update when user closes the notification
481 // Store current level temporarily so we can update it later
482 update_option('embedpress_milestone_current_level', $current_level);
483 update_option('embedpress_milestone_current_trigger', 'milestone_level');
484 update_option('is_embedpress_milestone_showing', true);
485 return true;
486 }
487
488 return false;
489 }
490
491 /**
492 * Whether the "What's New" feature-preview modal is queued for this
493 * request. When it is, the modal is the single, higher-priority dashboard
494 * announcement and every other EmbedPress notice (milestone, menu tooltip)
495 * must stand down so the user never sees two at once.
496 *
497 * @return bool
498 */
499 private function whatsnew_modal_active()
500 {
501 if (!class_exists('\\EmbedPress\\Includes\\Classes\\FeaturePreviewModal')) {
502 return false;
503 }
504
505 return \EmbedPress\Includes\Classes\FeaturePreviewModal::get_instance()->has_active_modal();
506 }
507
508 /**
509 * AJAX handler to mark milestone as seen
510 */
511 public function ajax_mark_milestone_seen()
512 {
513 // Verify nonce
514 if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'embedpress_milestone_nonce')) {
515 wp_send_json_error('Invalid nonce');
516 return;
517 }
518
519 // Get the trigger type (version_update or milestone_level)
520 $trigger_type = get_option('embedpress_milestone_current_trigger', 'milestone_level');
521
522 // If triggered by version update, store the current version
523 if ($trigger_type === 'version_update') {
524 update_option('embedpress_last_milestone_version', EMBEDPRESS_VERSION);
525 }
526
527 // Get the current milestone level that was shown
528 $current_level = get_option('embedpress_milestone_current_level', '');
529
530 if (!empty($current_level)) {
531 // Mark this milestone level as seen (site-wide)
532 update_option('embedpress_milestone_level', $current_level);
533
534 // Clean up the temporary option
535 delete_option('embedpress_milestone_current_level');
536 }
537
538 // Clean up trigger type
539 delete_option('embedpress_milestone_current_trigger');
540
541 // Clear the "is showing" flag when user dismisses the milestone
542 // This allows the next milestone to be shown when conditions are met
543 delete_option('is_embedpress_milestone_showing');
544
545 wp_send_json_success();
546 }
547 }
548