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

108 lines 2.1 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
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit; // Exit if accessed directly.
8 }
9
10 /**
11 * Elementor maintenance.
12 *
13 * Elementor maintenance handler class is responsible for setting up Elementor
14 * activation and uninstallation hooks.
15 *
16 * @since 1.0.0
17 */
18 class Maintenance {
19
20 /**
21 * Activate Elementor.
22 *
23 * Set Elementor activation hook.
24 *
25 * Fired by `register_activation_hook` when the plugin is activated.
26 *
27 * @since 1.0.0
28 * @access public
29 * @static
30 */
31 public static function activation( $network_wide ) {
32 wp_clear_scheduled_hook( 'elementor/tracker/send_event' );
33
34 wp_schedule_event( time(), 'daily', 'elementor/tracker/send_event' );
35 flush_rewrite_rules();
36
37 if ( is_multisite() && $network_wide ) {
38 static::create_default_kit(
39 get_sites( [
40 'fields' => 'ids',
41 ] )
42 );
43
44 return;
45 }
46
47 static::create_default_kit();
48
49 set_transient( 'elementor_activation_redirect', true, MINUTE_IN_SECONDS );
50 }
51
52 /**
53 * Uninstall Elementor.
54 *
55 * Set Elementor uninstallation hook.
56 *
57 * Fired by `register_uninstall_hook` when the plugin is uninstalled.
58 *
59 * @since 1.0.0
60 * @access public
61 * @static
62 */
63 public static function uninstall() {
64 wp_clear_scheduled_hook( 'elementor/tracker/send_event' );
65 }
66
67 /**
68 * Init.
69 *
70 * Initialize Elementor Maintenance.
71 *
72 * @since 1.0.0
73 * @access public
74 * @static
75 */
76 public static function init() {
77 register_activation_hook( ELEMENTOR_PLUGIN_BASE, [ __CLASS__, 'activation' ] );
78 register_uninstall_hook( ELEMENTOR_PLUGIN_BASE, [ __CLASS__, 'uninstall' ] );
79
80 add_action( 'wpmu_new_blog', function ( $site_id ) {
81 if ( ! is_plugin_active_for_network( ELEMENTOR_PLUGIN_BASE ) ) {
82 return;
83 }
84
85 static::create_default_kit( [ $site_id ] );
86 } );
87 }
88
89 /**
90 * @param array $site_ids
91 */
92 private static function create_default_kit( array $site_ids = [] ) {
93 if ( ! empty( $site_ids ) ) {
94 foreach ( $site_ids as $site_id ) {
95 switch_to_blog( $site_id );
96
97 Manager::create_default_kit();
98
99 restore_current_blog();
100 };
101
102 return;
103 }
104
105 Manager::create_default_kit();
106 }
107 }
108