PluginProbe
Elementor Website Builder – more than just a page builder / 3.27.5
Elementor Website Builder – more than just a page builder v3.27.5
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / includes / maintenance.php

maintenance.php in Elementor Website Builder – more than just a page builder 3.27.5, at includes/maintenance.php

131 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3
4 use Elementor\Core\Kits\Manager;
5 use Elementor\Core\Upgrade\Manager as Upgrade_Manager;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Exit if accessed directly.
9 }
10
11 /**
12 * Elementor maintenance.
13 *
14 * Elementor maintenance handler class is responsible for setting up Elementor
15 * activation and uninstallation hooks.
16 *
17 * @since 1.0.0
18 */
19 class Maintenance {
20
21 /**
22 * Activate Elementor.
23 *
24 * Set Elementor activation hook.
25 *
26 * Fired by `register_activation_hook` when the plugin is activated.
27 *
28 * @since 1.0.0
29 * @access public
30 * @static
31 */
32 public static function activation( $network_wide ) {
33 wp_clear_scheduled_hook( 'elementor/tracker/send_event' );
34
35 wp_schedule_event( time(), 'daily', 'elementor/tracker/send_event' );
36 flush_rewrite_rules();
37
38 if ( is_multisite() && $network_wide ) {
39 static::create_default_kit(
40 get_sites( [
41 'fields' => 'ids',
42 ] )
43 );
44
45 return;
46 }
47
48 static::create_default_kit();
49 static::insert_defaults_options();
50
51 set_transient( 'elementor_activation_redirect', true, MINUTE_IN_SECONDS );
52 }
53
54 public static function insert_defaults_options() {
55 $history = Upgrade_Manager::get_installs_history();
56 if ( empty( $history ) ) {
57 $default_options = [
58 'elementor_font_display' => 'swap',
59 ];
60 foreach ( $default_options as $option_name => $option_value ) {
61 if ( \Elementor\Utils::is_empty( get_option( $option_name ) ) ) {
62 add_option( $option_name, $option_value );
63 }
64 }
65 }
66 }
67
68 public static function deactivation() {
69 Api::get_deactivation_data();
70 }
71
72 /**
73 * Uninstall Elementor.
74 *
75 * Set Elementor uninstallation hook.
76 *
77 * Fired by `register_uninstall_hook` when the plugin is uninstalled.
78 *
79 * @since 1.0.0
80 * @access public
81 * @static
82 */
83 public static function uninstall() {
84 wp_clear_scheduled_hook( 'elementor/tracker/send_event' );
85
86 Api::get_uninstalled_data();
87 }
88
89 /**
90 * Init.
91 *
92 * Initialize Elementor Maintenance.
93 *
94 * @since 1.0.0
95 * @access public
96 * @static
97 */
98 public static function init() {
99 register_activation_hook( ELEMENTOR_PLUGIN_BASE, [ __CLASS__, 'activation' ] );
100 register_deactivation_hook( ELEMENTOR_PLUGIN_BASE, [ __CLASS__, 'deactivation' ] );
101 register_uninstall_hook( ELEMENTOR_PLUGIN_BASE, [ __CLASS__, 'uninstall' ] );
102
103 add_action( 'wpmu_new_blog', function ( $site_id ) {
104 if ( ! is_plugin_active_for_network( ELEMENTOR_PLUGIN_BASE ) ) {
105 return;
106 }
107
108 static::create_default_kit( [ $site_id ] );
109 } );
110 }
111
112 /**
113 * @param array $site_ids
114 */
115 private static function create_default_kit( array $site_ids = [] ) {
116 if ( ! empty( $site_ids ) ) {
117 foreach ( $site_ids as $site_id ) {
118 switch_to_blog( $site_id );
119
120 Manager::create_default_kit();
121
122 restore_current_blog();
123 };
124
125 return;
126 }
127
128 Manager::create_default_kit();
129 }
130 }
131