Skip to content

Commit 259fca3

Browse files
committed
v9.1.12
Signed-off-by: Kolja Nolte <kolja.nolte@gmail.com>
1 parent 1f5d0d5 commit 259fca3

54 files changed

Lines changed: 1213 additions & 1004 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.DS_Store

8 KB
Binary file not shown.

.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.nvmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

_importbuddy/importbuddy/.DS_Store

6 KB
Binary file not shown.

assets/.DS_Store

6 KB
Binary file not shown.

assets/dist/.DS_Store

6 KB
Binary file not shown.

backupbuddy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Solid Backups
44
* Plugin URI: https://go.solidwp.com/solid-backups-home
55
* Description: Safely store your website with automated backups and one click restore.
6-
* Version: 9.1.10
6+
* Version: 9.1.12
77
* Author: SolidWP
88
* Author URI: https://go.solidwp.com/solid-backups-home
99
*

classes/.DS_Store

6 KB
Binary file not shown.

classes/backup.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,14 @@ public function process_backup( $serial, $trigger = 'manual' ) {
11991199

12001200
pb_backupbuddy::status( 'details', 'Completed step function `' . $step['function'] . '`.' );
12011201

1202+
Solid_Backups_Telemetry::trackEvent(
1203+
'backup_complete',
1204+
[
1205+
'backup_type' => $this->_backup['type'],
1206+
'backup_trigger' => $this->_backup['trigger'],
1207+
]
1208+
);
1209+
12021210
return true;
12031211
}
12041212

classes/class-telemetry.php

Lines changed: 164 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
/**
33
* StellarWP Telemetry functions.
44
*
5-
* @link https://github.com/stellarwp/telemetry
5+
* @link https://github.com/stellarwp/telemetry
66
*
77
* @package Solid_Backups
8-
* @since 9.1.6
8+
* @since 9.1.6
99
*/
1010

1111
use Solid_Backups\Strauss\StellarWP\Telemetry\Config;
1212
use Solid_Backups\Strauss\StellarWP\Telemetry\Core as Telemetry;
1313
use Solid_Backups\Strauss\StellarWP\Telemetry\Opt_In\Status;
1414

15-
Class Solid_Backups_Telemetry {
15+
class Solid_Backups_Telemetry {
1616

1717
// The plugin slug.
1818
const SLUG = 'solid-backups';
@@ -22,14 +22,15 @@ public static function run_hooks() {
2222
add_action( 'admin_footer', array( __CLASS__, 'render_opt_in' ), 99 );
2323
add_filter( 'stellarwp/telemetry/optin_args', array( __CLASS__, 'optin_args' ), 10, 2 );
2424
add_action( 'admin_init', array( __CLASS__, 'save_opt_in_setting_field' ) );
25+
add_filter( 'debug_information', [ __CLASS__, 'add_site_health_info' ] );
2526
}
2627

2728
/**
2829
* Initialize the Telemetry library.
2930
*
3031
* @action plugins_loaded
3132
*
32-
* @since 9.1.6
33+
* @since 9.1.6
3334
*/
3435
public static function initialize() {
3536
$container = new Solid_Backups\Container();
@@ -48,13 +49,13 @@ public static function initialize() {
4849
/**
4950
* Customize the Telemetry opt-in modal.
5051
*
51-
* @since 9.1.6
52+
* @since 9.1.6
5253
*
5354
* @filter stellarwp/telemetry/optin_args
5455
*
55-
* @link https://github.com/stellarwp/telemetry/blob/develop/docs/filters.md#stellarwptelemetryoptin_args
56+
* @link https://github.com/stellarwp/telemetry/blob/develop/docs/filters.md#stellarwptelemetryoptin_args
5657
*
57-
* @param array $args The default arguments.
58+
* @param array $args The default arguments.
5859
* @param string $slug The plugin slug.
5960
*
6061
* @return array
@@ -65,7 +66,7 @@ public static function optin_args( $args, $slug ) {
6566
$args['plugin_slug'] = self::SLUG;
6667
$args['heading'] = __( 'Help us improve Solid Backups', 'it-l10n-backupbuddy' );
6768
$args['intro'] = sprintf(
68-
// translators: The user's display name.
69+
// translators: The user's display name.
6970
esc_html__( 'Hi %s! At Solid, we\'re committed to delivering top-notch services, and your valuable insights play a crucial role in helping us achieve that goal. We\'re excited to invite you to participate in our opt-in program, designed to enhance your experience with Solid Backups and contribute to the continuous improvement of StellarWP products. By opting in, you allow our teams to access certain data related to your website data. This information will be used responsibly to gain insights into your preferences and patterns, enabling us to tailor our services and products to better meet your needs. Rest assured, we take data privacy seriously, and our usage of your information will adhere to the highest standards, respecting all relevant regulations and guidelines. Your trust means the world to us, and we are committed to maintaining the confidentiality and security of your data. To join this initiative and be part of shaping the future of Solid Backups and StellarWP, simply click “Allow & Continue” below.', 'it-l10n-backupbuddy' ),
7071
$args['user_name']
7172
);
@@ -90,7 +91,7 @@ public static function optin_args( $args, $slug ) {
9091
* For testing, use the WP-CLI command
9192
* wp option delete stellarwp_telemetry
9293
*
93-
* @since 9.1.6
94+
* @since 9.1.6
9495
*
9596
* @action current_screen
9697
*/
@@ -110,22 +111,22 @@ public static function render_opt_in() {
110111
* Note that this Solid Backups setting is saved elsewhere.
111112
* This simply sets the value in the Telemetry library.
112113
*
113-
* @since 9.1.6
114+
* @since 9.1.6
114115
*
115116
* @action admin_init
116117
*
117118
* @return void
118119
*/
119120
public static function save_opt_in_setting_field() {
120121
// Return early if not saving the Opt In Status field.
121-
if ( ! isset( $_POST[ 'pb_backupbuddy_telemetry_opt_in_status' ] ) ) {
122+
if ( ! isset( $_POST['pb_backupbuddy_telemetry_opt_in_status'] ) ) {
122123
return;
123124
}
124125

125126
// Get an instance of the Status class.
126127
$status = Config::get_container()->get( Status::class );
127128

128-
$value = ! empty( intval( $_POST[ 'pb_backupbuddy_telemetry_opt_in_status' ] ) );
129+
$value = ! empty( intval( $_POST['pb_backupbuddy_telemetry_opt_in_status'] ) );
129130
$status->set_status( $value );
130131
}
131132

@@ -144,12 +145,162 @@ public static function save_opt_in_setting_field() {
144145
*
145146
* @since 9.1.6
146147
*
147-
* @see StellarWP\Telemetry\Opt_In\Status
148+
* @see StellarWP\Telemetry\Opt_In\Status
148149
*
149150
* @return int
150151
*/
151152
public static function get_opt_in_status_value() {
152153
$container = Telemetry::instance()->container();
154+
153155
return (int) $container->get( Status::class )->is_active();
154156
}
157+
158+
/**
159+
* Track the currently activated destinations
160+
*
161+
* @return array
162+
*/
163+
public static function add_site_health_info( $info ): array {
164+
165+
$site_size = backupbuddy_core::get_site_size();
166+
$database_size = backupbuddy_core::get_database_size();
167+
$database_method = pb_backupbuddy::$options['database_method_strategy'];
168+
169+
// Get the schedules and format for site info ( key = title, value = interval | backup type )
170+
$enabled_schedule_array_simplified = [];
171+
$disabled_schedule_array_simplified = [];
172+
foreach ( pb_backupbuddy::$options['schedules'] as $schedule ) {
173+
if ( $schedule['on_off'] ) {
174+
$enabled_schedule_array_simplified[ $schedule['title'] ] = $schedule['interval'] . ' | ' . pb_backupbuddy::$options['profiles'][ $schedule['profile'] ]['title'];
175+
} else {
176+
$disabled_schedule_array_simplified[ $schedule['title'] ] = $schedule['interval'] . ' | ' . pb_backupbuddy::$options['profiles'][ $schedule['profile'] ]['title'];
177+
}
178+
}
179+
180+
// Get the destinations and format for site info ( key = type, value = title )
181+
$destinations_simplified = [];
182+
$stash_active = false;
183+
foreach ( pb_backupbuddy::$options['remote_destinations'] as $destination ) {
184+
if ( $destination['type'] === 'live' ) {
185+
$stash_active = true;
186+
} else {
187+
$destinations_simplified[ $destination['type'] ] = $destination['title'];
188+
}
189+
}
190+
191+
$info['solid-backups'] = [
192+
'label' => __( 'Solid Backups', 'it-l10n-backupbuddy' ),
193+
'fields' => [
194+
'active_destinations' => [
195+
'label' => __( 'Active Destinations', 'it-l10n-backupbuddy' ),
196+
'value' => $destinations_simplified,
197+
'debug' => $destinations_simplified,
198+
],
199+
'active_schedules' => [
200+
'label' => __( 'Active Schedules', 'it-l10n-backupbuddy' ),
201+
'value' => $enabled_schedule_array_simplified,
202+
'debug' => $enabled_schedule_array_simplified,
203+
],
204+
'inactive_schedules' => [
205+
'label' => __( 'Inactive Schedules', 'it-l10n-backupbuddy' ),
206+
'value' => $disabled_schedule_array_simplified,
207+
'debug' => $disabled_schedule_array_simplified,
208+
],
209+
'stash_live_active' => [
210+
'label' => __( 'Stash Live Active', 'it-l10n-backupbuddy' ),
211+
'value' => $stash_active ? __( 'Yes', 'it-l10n-backupbuddy' ) : __( 'No', 'it-l10n-backupbuddy' ),
212+
'debug' => $stash_active,
213+
],
214+
'network_activated' => [
215+
'label' => __( 'Network Activated', 'it-l10n-backupbuddy' ),
216+
'value' => backupbuddy_core::is_network_activated() ? __( 'Yes', 'it-l10n-backupbuddy' ) : __( 'No', 'it-l10n-backupbuddy' ),
217+
'debug' => backupbuddy_core::is_network_activated(),
218+
],
219+
'backup_directory_override' => [
220+
'label' => __( 'Backup Directory Override', 'it-l10n-backupbuddy' ),
221+
'value' => '' != pb_backupbuddy::$options['backup_directory'] ? __( 'Yes', 'it-l10n-backupbuddy' ) : __( 'No', 'it-l10n-backupbuddy' ),
222+
'debug' => '' != pb_backupbuddy::$options['backup_directory'],
223+
],
224+
'site_size_total' => [
225+
'label' => __( 'Total Site Size', 'it-l10n-backupbuddy' ),
226+
'value' => self::convertSizeToHumanReadable( $site_size[0] ),
227+
'debug' => $site_size[0],
228+
],
229+
'site_size_exclusions' => [
230+
'label' => __( 'Site Size minus exclusions', 'it-l10n-backupbuddy' ),
231+
'value' => self::convertSizeToHumanReadable( $site_size[1] ),
232+
'debug' => $site_size[1],
233+
],
234+
'number_of_objects' => [
235+
'label' => __( 'Total number of objects, files and folders', 'it-l10n-backupbuddy' ),
236+
'value' => $site_size[2],
237+
'debug' => $site_size[2],
238+
],
239+
'number_of_objects_exclusions' => [
240+
'label' => __( 'Total number of objects, files and folders, minus exclusions', 'it-l10n-backupbuddy' ),
241+
'value' => $site_size[3],
242+
'debug' => $site_size[3],
243+
],
244+
'database_size_total' => [
245+
'label' => __( 'Database size', 'it-l10n-backupbuddy' ),
246+
'value' => self::convertSizeToHumanReadable( $database_size[0] ),
247+
'debug' => $database_size[0],
248+
],
249+
'database_size_total_exclusions' => [
250+
'label' => __( 'Database size minus exclusions', 'it-l10n-backupbuddy' ),
251+
'value' => self::convertSizeToHumanReadable( $database_size[1] ),
252+
'debug' => $database_size[1],
253+
],
254+
'database_method' => [
255+
'label' => __( 'Database Method Strategy', 'it-l10n-backupbuddy' ),
256+
'value' => $database_method,
257+
'debug' => $database_method,
258+
],
259+
'force_compatibility' => [
260+
'label' => __( 'Force Compatibility Mode', 'it-l10n-backupbuddy' ),
261+
'value' => pb_backupbuddy::$options['force_compatibility'] ? __( 'Yes', 'it-l10n-backupbuddy' ) : __( 'No', 'it-l10n-backupbuddy' ),
262+
'debug' => pb_backupbuddy::$options['force_compatibility'],
263+
],
264+
'force_mysqldump_compatibility' => [
265+
'label' => __( 'Force Compatibility Mode for MySQL', 'it-l10n-backupbuddy' ),
266+
'value' => pb_backupbuddy::$options['force_mysqldump_compatibility'] ? __( 'Yes', 'it-l10n-backupbuddy' ) : __( 'No', 'it-l10n-backupbuddy' ),
267+
'debug' => pb_backupbuddy::$options['force_mysqldump_compatibility'],
268+
],
269+
'deployment_allowed' => [
270+
'label' => __( 'Deployments Allowed', 'it-l10n-backupbuddy' ),
271+
'value' => pb_backupbuddy::$options['deployment_allowed'] ? __( 'Yes', 'it-l10n-backupbuddy' ) : __( 'No', 'it-l10n-backupbuddy' ),
272+
'debug' => pb_backupbuddy::$options['deployment_allowed'],
273+
],
274+
]
275+
];
276+
277+
return $info;
278+
}
279+
280+
public static function convertSizeToHumanReadable( $bytes, $decimals = 2 ): string {
281+
$size = array(
282+
'B',
283+
'KB',
284+
'MB',
285+
'GB',
286+
'TB',
287+
'PB',
288+
'EB',
289+
'ZB',
290+
'YB',
291+
);
292+
$factor = floor( ( strlen( $bytes ) - 1 ) / 3 );
293+
294+
return sprintf( "%.{$decimals}f", $bytes / pow( 1024, $factor ) ) . ' ' . @$size[ $factor ];
295+
}
296+
297+
/**
298+
* @param $event_type
299+
* @param $event_data
300+
*
301+
* @return void
302+
*/
303+
public static function trackEvent( $event_type, $event_data ) {
304+
do_action( 'stellarwp/telemetry/' . self::SLUG . '/event', $event_type, $event_data );
305+
}
155306
}

0 commit comments

Comments
 (0)