maintenance.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace Elementor;
  3. if ( ! defined( 'ABSPATH' ) ) {
  4. exit; // Exit if accessed directly.
  5. }
  6. /**
  7. * Elementor maintenance.
  8. *
  9. * Elementor maintenance handler class is responsible for setting up Elementor
  10. * activation and uninstallation hooks.
  11. *
  12. * @since 1.0.0
  13. */
  14. class Maintenance {
  15. /**
  16. * Activate Elementor.
  17. *
  18. * Set Elementor activation hook.
  19. *
  20. * Fired by `register_activation_hook` when the plugin is activated.
  21. *
  22. * @since 1.0.0
  23. * @access public
  24. * @static
  25. */
  26. public static function activation( $network_wide ) {
  27. wp_clear_scheduled_hook( 'elementor/tracker/send_event' );
  28. wp_schedule_event( time(), 'daily', 'elementor/tracker/send_event' );
  29. flush_rewrite_rules();
  30. if ( is_multisite() && $network_wide ) {
  31. return;
  32. }
  33. set_transient( 'elementor_activation_redirect', true, MINUTE_IN_SECONDS );
  34. }
  35. /**
  36. * Uninstall Elementor.
  37. *
  38. * Set Elementor uninstallation hook.
  39. *
  40. * Fired by `register_uninstall_hook` when the plugin is uninstalled.
  41. *
  42. * @since 1.0.0
  43. * @access public
  44. * @static
  45. */
  46. public static function uninstall() {
  47. wp_clear_scheduled_hook( 'elementor/tracker/send_event' );
  48. }
  49. /**
  50. * Init.
  51. *
  52. * Initialize Elementor Maintenance.
  53. *
  54. * @since 1.0.0
  55. * @access public
  56. * @static
  57. */
  58. public static function init() {
  59. register_activation_hook( ELEMENTOR_PLUGIN_BASE, [ __CLASS__, 'activation' ] );
  60. register_uninstall_hook( ELEMENTOR_PLUGIN_BASE, [ __CLASS__, 'uninstall' ] );
  61. }
  62. }