/var/www/html_it/wp-content/plugins/elementor/modules/promotions/pointers/birthday.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php

namespace Elementor\Modules\Promotions\Pointers;

use 
Elementor\User;
use 
Elementor\Utils;

if ( ! 
defined'ABSPATH' ) ) {
    exit; 
// Exit if accessed directly.
}

class 
Birthday {
    const 
PROMOTION_URL 'https://go.elementor.com/go-pro-wordpress-notice-birthday/';
    const 
ELEMENTOR_POINTER_ID 'toplevel_page_elementor';
    const 
SEEN_TODAY_KEY '_elementor-2025-birthday';
    const 
DISMISS_ACTION_KEY 'birthday_pointer_2025';

    public function 
__construct() {
        
add_action'admin_print_footer_scripts-index.php', [ $this'enqueue_notice' ] );
    }

    public function 
enqueue_notice() {
        if ( ! 
$this->should_display_notice() ) {
            return;
        }

        
$this->set_seen_today();
        
$this->enqueue_dependencies();

        
$pointer_content '<h3>' esc_html__'Elementor’s 9th Birthday sale!''elementor' ) . '</h3>';
        
$pointer_content .= '<p>' esc_html__'Celebrate Elementor’s birthday with us—exclusive deals are available now.''elementor' );
        
$pointer_content .= sprintf(
            
'<p><a class="button button-primary" href="%s" target="_blank">%s</a></p>',
            
self::PROMOTION_URL,
            
esc_html__'View Deals''elementor' )
        );

        
$allowed_tags = [
            
'h3' => [],
            
'p' => [],
            
'a' => [
                
'class' => [],
                
'target' => [ '_blank' ],
                
'href' => [],
            ],
        ];
        
?>

        <script>
            jQuery( document ).ready( function( $ ) {
                $( "#<?php echo esc_attrself::ELEMENTOR_POINTER_ID ); ?>" ).pointer( {
                    content: '<?php echo wp_kses$pointer_content$allowed_tags ); ?>',
                    position: {
                        edge: <?php echo is_rtl() ? "'right'" "'left'"?>,
                        align: "center"
                    },
                    close: function() {
                        elementorCommon.ajax.addRequest( "introduction_viewed", {
                            data: {
                                introductionKey: '<?php echo esc_attr( static::DISMISS_ACTION_KEY ); ?>'
                            }
                        } );
                    }
                } ).pointer( "open" );
            } );
        </script>
        <?php
    
}

    public static function 
should_display_notice(): bool {
        return 
self::is_user_allowed() &&
            ! 
self::is_dismissed() &&
            
self::is_campaign_time() &&
            ! 
self::is_already_seen_today() &&
            ! 
Utils::has_pro();
    }

    private static function 
is_user_allowed(): bool {
        return 
current_user_can'manage_options' ) || current_user_can'edit_pages' );
    }

    private static function 
is_campaign_time() {
        
$start = new \DateTime'2025-06-10 12:00:00', new \DateTimeZone'UTC' ) );
        
$end = new \DateTime'2025-06-17 03:59:00', new \DateTimeZone'UTC' ) );
        
$now = new \DateTime'now', new \DateTimeZone'UTC' ) );

        return 
$now >= $start && $now <= $end;
    }

    private static function 
is_already_seen_today() {
        return 
get_transientself::get_user_transient_id() );
    }

    private function 
set_seen_today() {
        
$now time();
        
$midnight strtotime'tomorrow midnight' );
        
$seconds_until_midnight $midnight $now;

        
set_transientself::get_user_transient_id(), $now$seconds_until_midnight );
    }

    private static function 
get_user_transient_id(): string {
        return 
self::SEEN_TODAY_KEY '_' get_current_user_id();
    }

    private function 
enqueue_dependencies() {
        
wp_enqueue_script'wp-pointer' );
        
wp_enqueue_style'wp-pointer' );
    }

    private static function 
is_dismissed(): bool {
        return 
User::get_introduction_meta( static::DISMISS_ACTION_KEY );
    }
}