/var/www/html_us/wp-content/plugins/elementor/includes/maintenance.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
namespace Elementor;

use 
Elementor\Core\Kits\Manager;
use 
Elementor\Core\Upgrade\Manager as Upgrade_Manager;

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

/**
 * Elementor maintenance.
 *
 * Elementor maintenance handler class is responsible for setting up Elementor
 * activation and uninstallation hooks.
 *
 * @since 1.0.0
 */
class Maintenance {

    
/**
     * Activate Elementor.
     *
     * Set Elementor activation hook.
     *
     * Fired by `register_activation_hook` when the plugin is activated.
     *
     * @since 1.0.0
     * @access public
     * @static
     */
    
public static function activation$network_wide ) {
        
wp_clear_scheduled_hook'elementor/tracker/send_event' );

        
wp_schedule_eventtime(), 'daily''elementor/tracker/send_event' );
        
flush_rewrite_rules();

        if ( 
is_multisite() && $network_wide ) {
            static::
create_default_kit(
                
get_sites( [
                    
'fields' => 'ids',
                ] )
            );

            return;
        }

        static::
create_default_kit();
        static::
insert_defaults_options();

        
set_transient'elementor_activation_redirect'trueMINUTE_IN_SECONDS );
    }

    public static function 
insert_defaults_options() {
        
$history Upgrade_Manager::get_installs_history();
        if ( empty( 
$history ) ) {
            
$default_options = [
                
'elementor_font_display' => 'swap',
            ];
            foreach ( 
$default_options as $option_name => $option_value ) {
                if ( 
\Elementor\Utils::is_emptyget_option$option_name ) ) ) {
                    
add_option$option_name$option_value );
                }
            }
        }
    }

    public static function 
deactivation() {
        
Api::get_deactivation_data();
    }

    
/**
     * Uninstall Elementor.
     *
     * Set Elementor uninstallation hook.
     *
     * Fired by `register_uninstall_hook` when the plugin is uninstalled.
     *
     * @since 1.0.0
     * @access public
     * @static
     */
    
public static function uninstall() {
        
wp_clear_scheduled_hook'elementor/tracker/send_event' );

        
Api::get_uninstalled_data();
    }

    
/**
     * Init.
     *
     * Initialize Elementor Maintenance.
     *
     * @since 1.0.0
     * @access public
     * @static
     */
    
public static function init() {
        
register_activation_hookELEMENTOR_PLUGIN_BASE, [ __CLASS__'activation' ] );
        
register_deactivation_hookELEMENTOR_PLUGIN_BASE, [ __CLASS__'deactivation' ] );
        
register_uninstall_hookELEMENTOR_PLUGIN_BASE, [ __CLASS__'uninstall' ] );

        
add_action'wpmu_new_blog', function ( $site_id ) {
            if ( ! 
is_plugin_active_for_networkELEMENTOR_PLUGIN_BASE ) ) {
                return;
            }

            static::
create_default_kit( [ $site_id ] );
        } );
    }

    
/**
     * @param array $site_ids
     */
    
private static function create_default_kit( array $site_ids = [] ) {
        if ( ! empty( 
$site_ids ) ) {
            foreach ( 
$site_ids as $site_id ) {
                
switch_to_blog$site_id );

                
Manager::create_default_kit();

                
restore_current_blog();
            };

            return;
        }

        
Manager::create_default_kit();
    }
}