PluginProbe
Elementor Website Builder – more than just a page builder / 3.22.1
Elementor Website Builder – more than just a page builder v3.22.1
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.22.1, at includes/maintenance.php

124 lines 2.6 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 /**
69 * Uninstall Elementor.
70 *
71 * Set Elementor uninstallation hook.
72 *
73 * Fired by `register_uninstall_hook` when the plugin is uninstalled.
74 *
75 * @since 1.0.0
76 * @access public
77 * @static
78 */
79 public static function uninstall() {
80 wp_clear_scheduled_hook( 'elementor/tracker/send_event' );
81 }
82
83 /**
84 * Init.
85 *
86 * Initialize Elementor Maintenance.
87 *
88 * @since 1.0.0
89 * @access public
90 * @static
91 */
92 public static function init() {
93 register_activation_hook( ELEMENTOR_PLUGIN_BASE, [ __CLASS__, 'activation' ] );
94 register_uninstall_hook( ELEMENTOR_PLUGIN_BASE, [ __CLASS__, 'uninstall' ] );
95
96 add_action( 'wpmu_new_blog', function ( $site_id ) {
97 if ( ! is_plugin_active_for_network( ELEMENTOR_PLUGIN_BASE ) ) {
98 return;
99 }
100
101 static::create_default_kit( [ $site_id ] );
102 } );
103 }
104
105 /**
106 * @param array $site_ids
107 */
108 private static function create_default_kit( array $site_ids = [] ) {
109 if ( ! empty( $site_ids ) ) {
110 foreach ( $site_ids as $site_id ) {
111 switch_to_blog( $site_id );
112
113 Manager::create_default_kit();
114
115 restore_current_blog();
116 };
117
118 return;
119 }
120
121 Manager::create_default_kit();
122 }
123 }
124