PluginProbe
Jetpack VaultPress Backup / 1.1.0
Jetpack VaultPress Backup v1.1.0
3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7.1 3.8 3.9 trunk 0.2.0 1.0.0 1.0.1 1.1.0 1.2.0 1.3.0 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5 1.6 1.7 All 37 releases
jetpack-backup / jetpack-backup.php

jetpack-backup.php in Jetpack VaultPress Backup 1.1.0, at jetpack-backup.php

142 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 * Plugin Name: Jetpack Backup
5 * Plugin URI: https://jetpack.com/jetpack-backup
6 * Description: Easily restore or download a backup of your site from a specific moment in time.
7 * Version: 1.1.0
8 * Author: Automattic
9 * Author URI: https://jetpack.com/
10 * License: GPLv2 or later
11 * Text Domain: jetpack-backup
12 *
13 * @package automattic/jetpack-backup-plugin
14 */
15
16 /*
17 This program is free software; you can redistribute it and/or
18 modify it under the terms of the GNU General Public License
19 as published by the Free Software Foundation; either version 2
20 of the License, or (at your option) any later version.
21
22 This program is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 GNU General Public License for more details.
26
27 You should have received a copy of the GNU General Public License
28 along with this program; if not, write to the Free Software
29 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30 */
31
32 if ( ! defined( 'ABSPATH' ) ) {
33 exit;
34 }
35
36 // Constant definitions.
37 define( 'JETPACK_BACKUP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
38 define( 'JETPACK_BACKUP_PLUGIN_ROOT_FILE', __FILE__ );
39 define( 'JETPACK_BACKUP_PLUGIN_ROOT_FILE_RELATIVE_PATH', plugin_basename( __FILE__ ) );
40 define( 'JETPACK_BACKUP_PLUGIN_SLUG', 'jetpack-backup' );
41 define( 'JETPACK_BACKUP_PLUGIN_NAME', 'Jetpack Backup' );
42 define( 'JETPACK_BACKUP_PLUGIN_URI', 'https://jetpack.com/jetpack-backup' );
43 define( 'JETPACK_BACKUP_REQUIRED_JETPACK_VERSION', '10.0' );
44 define( 'JETPACK_BACKUP_PLUGIN_FOLDER', dirname( plugin_basename( __FILE__ ) ) );
45 define( 'JETPACK_BACKUP_PROMOTED_PRODUCT', 'jetpack_backup_t1_yearly' );
46
47 /**
48 * Checks if Jetpack is installed and if yes, require version 10+
49 * Can be extended to check for various system requiremens, such as WP or PHP version.
50 *
51 * @return bool|WP_Error True if system requirements are met, WP_Error if not.
52 */
53 function jetpack_backup_requirements_check() {
54 require_once ABSPATH . '/wp-admin/includes/plugin.php'; // to get is_plugin_active() early.
55
56 if ( ! is_plugin_active( 'jetpack/jetpack.php' ) ) {
57 return true;
58 }
59
60 $jetpack_plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/jetpack/jetpack.php', false, false );
61
62 if ( version_compare( $jetpack_plugin_data['Version'], JETPACK_BACKUP_REQUIRED_JETPACK_VERSION, '<' ) ) {
63 return new WP_Error(
64 'incompatible_jetpack_version',
65 __( 'The Jetpack Backup plugin requires version 10 or higher of the Jetpack plugin. Please update your Jetpack plugin to continue.', 'jetpack-backup' )
66 );
67 }
68 return true;
69 }
70
71 $jetpack_backup_meets_requirements = jetpack_backup_requirements_check();
72 if ( is_wp_error( $jetpack_backup_meets_requirements ) ) {
73 add_action(
74 'admin_notices',
75 function () use ( $jetpack_backup_meets_requirements ) {
76 ?>
77 <div class="notice notice-error is-dismissible">
78 <p>
79 <?php
80 echo esc_html( $jetpack_backup_meets_requirements->get_error_message() );
81 ?>
82 </p>
83 </div>
84 <?php
85 }
86 );
87
88 return;
89 }
90
91 // Jetpack Autoloader.
92 $jetpack_autoloader = JETPACK_BACKUP_PLUGIN_DIR . 'vendor/autoload_packages.php';
93 if ( is_readable( $jetpack_autoloader ) ) {
94 require_once $jetpack_autoloader;
95 if ( method_exists( \Automattic\Jetpack\Assets::class, 'alias_textdomains_from_file' ) ) {
96 \Automattic\Jetpack\Assets::alias_textdomains_from_file( JETPACK_BACKUP_PLUGIN_DIR . 'jetpack_vendor/i18n-map.php' );
97 }
98 } else { // Something very unexpected. Error out gently with an admin_notice and exit loading.
99 if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
100 error_log( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
101 __( 'Error loading autoloader file for Jetpack Backup plugin', 'jetpack-backup' )
102 );
103 }
104
105 add_action(
106 'admin_notices',
107 function () {
108 ?>
109 <div class="notice notice-error is-dismissible">
110 <p>
111 <?php
112 printf(
113 wp_kses(
114 /* translators: Placeholder is a link to a support document. */
115 __( 'Your installation of Jetpack Backup is incomplete. If you installed Jetpack Backup from GitHub, please refer to <a href="%1$s" target="_blank" rel="noopener noreferrer">this document</a> to set up your development environment. Jetpack Backup must have Composer dependencies installed and built via the build command.', 'jetpack-backup' ),
116 array(
117 'a' => array(
118 'href' => array(),
119 'target' => array(),
120 'rel' => array(),
121 ),
122 )
123 ),
124 'https://github.com/Automattic/jetpack/blob/master/docs/development-environment.md#building-your-project'
125 );
126 ?>
127 </p>
128 </div>
129 <?php
130 }
131 );
132
133 return;
134 }
135
136 // Redirect to plugin page when the plugin is activated.
137 add_action( 'activated_plugin', array( 'Jetpack_Backup', 'plugin_activation' ) );
138
139 register_deactivation_hook( __FILE__, array( 'Jetpack_Backup', 'plugin_deactivation' ) );
140 // Main plugin class.
141 new Jetpack_Backup();
142