Aucune description

vaultpress.php 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Handles VaultPress->Rewind transition by deactivating VaultPress when needed.
  4. *
  5. * @package automattic/jetpack
  6. */
  7. use Automattic\Jetpack\Redirect;
  8. /**
  9. * Notify user that VaultPress has been disabled. Hide VaultPress notice that requested attention.
  10. *
  11. * @since 5.8
  12. */
  13. function jetpack_vaultpress_rewind_enabled_notice() {
  14. // The deactivation is performed here because there may be pages that admin_init runs on,
  15. // such as admin_ajax, that could deactivate the plugin without showing this notification.
  16. deactivate_plugins( 'vaultpress/vaultpress.php' );
  17. // Remove WP core notice that says that the plugin was activated.
  18. unset( $_GET['activate'] ); // phpcs:ignore WordPress.Security.NonceVerification
  19. ?>
  20. <div class="notice notice-success is-dismissible vp-deactivated">
  21. <p style="margin-bottom: 0.25em;"><strong><?php esc_html_e( 'Jetpack is now handling your backups.', 'jetpack' ); ?></strong></p>
  22. <p>
  23. <?php esc_html_e( 'VaultPress is no longer needed and has been deactivated.', 'jetpack' ); ?>
  24. <?php
  25. echo sprintf(
  26. wp_kses(
  27. /* Translators: first variable is the full URL to the new dashboard */
  28. __( 'You can access your backups at <a href="%s" target="_blank" rel="noopener noreferrer">this dashboard</a>.', 'jetpack' ),
  29. array(
  30. 'a' => array(
  31. 'href' => array(),
  32. 'target' => array(),
  33. 'rel' => array(),
  34. ),
  35. )
  36. ),
  37. esc_url( Redirect::get_url( 'calypso-backups' ) )
  38. );
  39. ?>
  40. </p>
  41. </div>
  42. <style>#vp-notice{display:none;}</style>
  43. <?php
  44. }
  45. /**
  46. * If Backup & Scan is enabled, remove its entry in sidebar, deactivate VaultPress, and show a notification.
  47. *
  48. * @since 5.8
  49. */
  50. function jetpack_vaultpress_rewind_check() {
  51. if (
  52. Jetpack::is_connection_ready() &&
  53. Jetpack::is_plugin_active( 'vaultpress/vaultpress.php' ) &&
  54. Jetpack::is_rewind_enabled()
  55. ) {
  56. remove_submenu_page( 'jetpack', 'vaultpress' );
  57. add_action( 'admin_notices', 'jetpack_vaultpress_rewind_enabled_notice' );
  58. }
  59. }
  60. add_action( 'admin_init', 'jetpack_vaultpress_rewind_check', 11 );