vaultpress.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Notify user that VaultPress has been disabled. Hide VaultPress notice that requested attention.
  4. *
  5. * @since 5.8
  6. */
  7. function jetpack_vaultpress_rewind_enabled_notice() {
  8. // The deactivation is performed here because there may be pages that admin_init runs on,
  9. // such as admin_ajax, that could deactivate the plugin without showing this notification.
  10. deactivate_plugins( 'vaultpress/vaultpress.php' );
  11. // Remove WP core notice that says that the plugin was activated.
  12. if ( isset( $_GET['activate'] ) ) {
  13. unset( $_GET['activate'] );
  14. }
  15. ?>
  16. <div class="notice notice-success vp-deactivated">
  17. <h2 style="margin-bottom: 0.25em;"><?php _e( 'Jetpack is now handling your backups.', 'jetpack' ); ?></h2>
  18. <p><?php _e( 'VaultPress is no longer needed and has been deactivated.', 'jetpack' ); ?></p>
  19. </div>
  20. <style>#vp-notice{display:none;}</style>
  21. <?php
  22. }
  23. /**
  24. * If Rewind is enabled, remove its entry in sidebar, deactivate VaultPress, and show a notification.
  25. *
  26. * @since 5.8
  27. */
  28. function jetpack_vaultpress_rewind_check() {
  29. if ( Jetpack::is_active() &&
  30. Jetpack::is_plugin_active( 'vaultpress/vaultpress.php' ) &&
  31. Jetpack::is_rewind_enabled()
  32. ) {
  33. remove_submenu_page( 'jetpack', 'vaultpress' );
  34. add_action( 'admin_notices', 'jetpack_vaultpress_rewind_enabled_notice' );
  35. }
  36. }
  37. add_action( 'admin_init', 'jetpack_vaultpress_rewind_check', 11 );