admin-templates
4 years ago
base
4 years ago
controls
4 years ago
editor-templates
4 years ago
elements
4 years ago
interfaces
6 years ago
libraries
5 years ago
managers
4 years ago
settings
4 years ago
template-library
4 years ago
widgets
4 years ago
api.php
4 years ago
autoloader.php
4 years ago
beta-testers.php
6 years ago
compatibility.php
4 years ago
conditions.php
6 years ago
db.php
5 years ago
embed.php
4 years ago
fonts.php
4 years ago
frontend.php
4 years ago
heartbeat.php
7 years ago
maintenance-mode.php
4 years ago
maintenance.php
4 years ago
plugin.php
4 years ago
preview.php
4 years ago
rollback.php
4 years ago
shapes.php
6 years ago
stylesheet.php
4 years ago
tracker.php
4 years ago
user.php
4 years ago
utils.php
4 years ago
maintenance.php
106 lines
| 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( [ 'fields' => 'ids' ] ) |
| 40 | ); |
| 41 | |
| 42 | return; |
| 43 | } |
| 44 | |
| 45 | static::create_default_kit(); |
| 46 | |
| 47 | set_transient( 'elementor_activation_redirect', true, MINUTE_IN_SECONDS ); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Uninstall Elementor. |
| 52 | * |
| 53 | * Set Elementor uninstallation hook. |
| 54 | * |
| 55 | * Fired by `register_uninstall_hook` when the plugin is uninstalled. |
| 56 | * |
| 57 | * @since 1.0.0 |
| 58 | * @access public |
| 59 | * @static |
| 60 | */ |
| 61 | public static function uninstall() { |
| 62 | wp_clear_scheduled_hook( 'elementor/tracker/send_event' ); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Init. |
| 67 | * |
| 68 | * Initialize Elementor Maintenance. |
| 69 | * |
| 70 | * @since 1.0.0 |
| 71 | * @access public |
| 72 | * @static |
| 73 | */ |
| 74 | public static function init() { |
| 75 | register_activation_hook( ELEMENTOR_PLUGIN_BASE, [ __CLASS__, 'activation' ] ); |
| 76 | register_uninstall_hook( ELEMENTOR_PLUGIN_BASE, [ __CLASS__, 'uninstall' ] ); |
| 77 | |
| 78 | add_action( 'wpmu_new_blog', function ( $site_id ) { |
| 79 | if ( ! is_plugin_active_for_network( ELEMENTOR_PLUGIN_BASE ) ) { |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | static::create_default_kit( [ $site_id ] ); |
| 84 | } ); |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * @param array $site_ids |
| 89 | */ |
| 90 | private static function create_default_kit( array $site_ids = [] ) { |
| 91 | if ( ! empty( $site_ids ) ) { |
| 92 | foreach ( $site_ids as $site_id ) { |
| 93 | switch_to_blog( $site_id ); |
| 94 | |
| 95 | Manager::create_default_kit(); |
| 96 | |
| 97 | restore_current_blog(); |
| 98 | }; |
| 99 | |
| 100 | return; |
| 101 | } |
| 102 | |
| 103 | Manager::create_default_kit(); |
| 104 | } |
| 105 | } |
| 106 |