VaultPress - Version 1.8.0

Version Description

  • 7 Mar 2016 =
  • Add support for an upcoming ability to have the Jetpack plugin manage registering the VaultPress plugin and entering the required API key. Gone will be the days of needing to copy/paste it!
Download this release

Release Info

Developer Viper007Bond
Plugin Icon 128x128 VaultPress
Version 1.8.0
Comparing to
See all releases

Code changes from version 1.7.9 to 1.8.0

Files changed (2) hide show
  1. readme.txt +3 -0
  2. vaultpress.php +59 -5
readme.txt CHANGED
@@ -51,6 +51,9 @@ A VaultPress subscription is for a single WordPress site. You can purchase addit
51
  Yes, VaultPress supports Multisite installs. Each site will require its own subscription.
52
 
53
  == Changelog ==
 
 
 
54
  = 1.7.9 - 24 Feb 2016 =
55
  * PHP 7 support. Drop support for PHP 4 and versions of WordPress older than 3.2.
56
  * Silence PHP errors when attempting to change the execution time limit when PHP is running in safe mode.
51
  Yes, VaultPress supports Multisite installs. Each site will require its own subscription.
52
 
53
  == Changelog ==
54
+ = 1.8.0 - 7 Mar 2016 =
55
+ * Add support for an upcoming ability to have the Jetpack plugin manage registering the VaultPress plugin and entering the required API key. Gone will be the days of needing to copy/paste it!
56
+
57
  = 1.7.9 - 24 Feb 2016 =
58
  * PHP 7 support. Drop support for PHP 4 and versions of WordPress older than 3.2.
59
  * Silence PHP errors when attempting to change the execution time limit when PHP is running in safe mode.
vaultpress.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: VaultPress
4
  * Plugin URI: http://vaultpress.com/?utm_source=plugin-uri&utm_medium=plugin-description&utm_campaign=1.0
5
  * Description: Protect your content, themes, plugins, and settings with <strong>realtime backup</strong> and <strong>automated security scanning</strong> from <a href="http://vaultpress.com/?utm_source=wp-admin&amp;utm_medium=plugin-description&amp;utm_campaign=1.0" rel="nofollow">VaultPress</a>. Activate, enter your registration key, and never worry again. <a href="http://vaultpress.com/help/?utm_source=wp-admin&amp;utm_medium=plugin-description&amp;utm_campaign=1.0" rel="nofollow">Need some help?</a>
6
- * Version: 1.7.9
7
  * Author: Automattic
8
  * Author URI: http://vaultpress.com/?utm_source=author-uri&amp;utm_medium=plugin-description&amp;utm_campaign=1.0
9
  * License: GPL2+
@@ -15,9 +15,10 @@
15
  defined( 'ABSPATH' ) or die();
16
 
17
  class VaultPress {
18
- var $option_name = 'vaultpress';
19
- var $db_version = 4;
20
- var $plugin_version = '1.7.9';
 
21
 
22
  function __construct() {
23
  register_activation_hook( __FILE__, array( $this, 'activate' ) );
@@ -40,8 +41,11 @@ class VaultPress {
40
 
41
  $this->upgrade();
42
 
43
- if ( is_admin() )
 
 
44
  $this->add_admin_actions_and_filters();
 
45
 
46
  if ( $this->is_registered() ) {
47
  $do_not_backup = $this->get_option( 'do_not_backup' ) || $this->get_option( 'do_not_send_backup_pings' );
@@ -2236,6 +2240,56 @@ JS;
2236
  return $site_url;
2237
  }
2238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2239
  function add_admin_actions_and_filters() {
2240
  add_action( 'admin_init', array( $this, 'admin_init' ) );
2241
  add_action( 'admin_menu', array( $this, 'admin_menu' ), 5 ); # Priority 5, so it's called before Jetpack's admin_menu.
3
  * Plugin Name: VaultPress
4
  * Plugin URI: http://vaultpress.com/?utm_source=plugin-uri&amp;utm_medium=plugin-description&amp;utm_campaign=1.0
5
  * Description: Protect your content, themes, plugins, and settings with <strong>realtime backup</strong> and <strong>automated security scanning</strong> from <a href="http://vaultpress.com/?utm_source=wp-admin&amp;utm_medium=plugin-description&amp;utm_campaign=1.0" rel="nofollow">VaultPress</a>. Activate, enter your registration key, and never worry again. <a href="http://vaultpress.com/help/?utm_source=wp-admin&amp;utm_medium=plugin-description&amp;utm_campaign=1.0" rel="nofollow">Need some help?</a>
6
+ * Version: 1.8.0
7
  * Author: Automattic
8
  * Author URI: http://vaultpress.com/?utm_source=author-uri&amp;utm_medium=plugin-description&amp;utm_campaign=1.0
9
  * License: GPL2+
15
  defined( 'ABSPATH' ) or die();
16
 
17
  class VaultPress {
18
+ var $option_name = 'vaultpress';
19
+ var $auto_register_option = 'vaultpress_auto_register';
20
+ var $db_version = 4;
21
+ var $plugin_version = '1.8.0';
22
 
23
  function __construct() {
24
  register_activation_hook( __FILE__, array( $this, 'activate' ) );
41
 
42
  $this->upgrade();
43
 
44
+ $this->add_global_actions_and_filters();
45
+
46
+ if ( is_admin() ) {
47
  $this->add_admin_actions_and_filters();
48
+ }
49
 
50
  if ( $this->is_registered() ) {
51
  $do_not_backup = $this->get_option( 'do_not_backup' ) || $this->get_option( 'do_not_send_backup_pings' );
2240
  return $site_url;
2241
  }
2242
 
2243
+ /**
2244
+ * Sync the VaultPress options to WordPress.com if the Jetpack plugin is active.
2245
+ */
2246
+ function sync_jetpack_options() {
2247
+ if ( class_exists( 'Jetpack_Sync' ) ) {
2248
+ Jetpack_Sync::sync_options( __FILE__, $this->auto_register_option, $this->option_name );
2249
+ }
2250
+ }
2251
+
2252
+ /**
2253
+ * Add the VaultPress options to the Jetpack options management whitelist.
2254
+ * Allows Jetpack to register VaultPress options automatically.
2255
+ *
2256
+ * @param array $options The list of whitelisted option names.
2257
+ *
2258
+ * @return array The updated whitelist
2259
+ */
2260
+ function add_to_jetpack_options_whitelist( $options ) {
2261
+ $options[] = $this->option_name;
2262
+ $options[] = $this->auto_register_option;
2263
+
2264
+ return $options;
2265
+ }
2266
+
2267
+ /**
2268
+ * When the VaultPress auto-register option is updated, run the registration call.
2269
+ *
2270
+ * This should only be run when the option is updated from the Jetpack/WP.com
2271
+ * API call, and only if the new key is different than the old key.
2272
+ *
2273
+ * @param mixed $old_value The old option value.
2274
+ * @param mixed $value The new option value.
2275
+ */
2276
+ function updated_auto_register_option( $old_value, $value ) {
2277
+ // Not an API call or CLI call
2278
+ if ( ! class_exists( 'WPCOM_JSON_API_Update_Option_Endpoint' ) && ! ( defined( 'WP_CLI' ) && WP_CLI ) ) {
2279
+ return;
2280
+ }
2281
+
2282
+ $this->register( $value );
2283
+ delete_option( $this->auto_register_option );
2284
+ }
2285
+
2286
+ function add_global_actions_and_filters() {
2287
+ add_action( 'init', array( $this, 'sync_jetpack_options' ), 0, 99 );
2288
+ add_filter( 'jetpack_options_whitelist', array( $this, 'add_to_jetpack_options_whitelist' ) );
2289
+ add_action( "update_option_{$this->auto_register_option}", array( $this, 'updated_auto_register_option' ), 10, 2 );
2290
+ add_action( "add_option_{$this->auto_register_option}", array( $this, 'updated_auto_register_option' ), 10, 2 );
2291
+ }
2292
+
2293
  function add_admin_actions_and_filters() {
2294
  add_action( 'admin_init', array( $this, 'admin_init' ) );
2295
  add_action( 'admin_menu', array( $this, 'admin_menu' ), 5 ); # Priority 5, so it's called before Jetpack's admin_menu.