PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.4
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.4
6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 5.2.2 5.3 All 153 releases
mainwp / modules / api-backups / classes / class-api-backups-utility.php

class-api-backups-utility.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 5.4, at modules/api-backups/classes/class-api-backups-utility.php

756 lines 25.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class Api_Backups_Utility
4 *
5 * @package MainWP\Dashboard
6 * @version 5.0
7 */
8
9 namespace MainWP\Dashboard\Module\ApiBackups;
10
11 use MainWP\Dashboard\MainWP_DB;
12 use MainWP\Dashboard\MainWP_Logger;
13 use MainWP\Dashboard\MainWP_System_Utility;
14
15 /**
16 * Class Api_Backups_Utility
17 */
18 class Api_Backups_Utility { //phpcs:ignore -- NOSONAR - multi methods.
19
20 /**
21 * Instance value.
22 *
23 * @var static Default null
24 */
25 public static $instance = null;
26
27 /**
28 * Get Instance
29 *
30 * Creates public static instance.
31 *
32 * @static
33 *
34 * @return Api_Backups_Utility
35 */
36 public static function get_instance() {
37 if ( null === static::$instance ) {
38 static::$instance = new self();
39 }
40 return static::$instance;
41 }
42
43 /**
44 * Method __construct.
45 */
46 public function __construct() {
47 // contructor.
48 }
49
50 /**
51 * Method count_child_sites().
52 */
53 public function count_child_sites() {
54 $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_wp_for_current_user() );
55
56 if ( ! empty( $websites ) ) {
57 $sites_count = MainWP_DB::num_rows( $websites );
58 }
59 // Free result set.
60 Api_Backups_Helper::free_result( $websites );
61
62 return $sites_count;
63 }
64
65 /**
66 * Get timestamp.
67 *
68 * @param int $timestamp Holds Timestamp.
69 *
70 * @return float|int Return GMT offset.
71 */
72 public static function get_timestamp( $timestamp = false ) {
73 if ( empty( $timestamp ) ) {
74 $timestamp = time();
75 }
76 $gmtOffset = get_option( 'gmt_offset' );
77
78 return $gmtOffset ? ( $gmtOffset * HOUR_IN_SECONDS ) + $timestamp : $timestamp;
79 }
80
81 /**
82 * Format timestamp.
83 *
84 * @param int $timestamp Holds Timestamp.
85 * @param bool $gmt Whether to set as General mountain time. Default: FALSE.
86 *
87 * @return string Return Timestamp.
88 */
89 public static function format_timestamp( $timestamp, $gmt = false ) {
90 return date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $timestamp, $gmt );
91 }
92
93 /**
94 * Format datestamp.
95 *
96 * @param int $timestamp Holds Timestamp.
97 * @param bool $gmt Whether to set as General mountain time. Default: FALSE.
98 *
99 * @return string Return Timestamp.
100 */
101 public static function format_datestamp( $timestamp, $gmt = false ) {
102 return date_i18n( get_option( 'date_format' ), $timestamp, $gmt );
103 }
104
105 /**
106 * Method map_fields()
107 *
108 * Map Site.
109 *
110 * @param mixed $website Website to map.
111 * @param mixed $keys Keys to map.
112 * @param bool $object_output Output format array|object.
113 *
114 * @return object $outputSite Mapped site.
115 */
116 public static function map_fields( &$website, $keys, $object_output = false ) { //phpcs:ignore -- NOSONAR - complex.
117 $outputSite = array();
118 if ( ! empty( $website ) ) {
119 if ( is_object( $website ) ) {
120 foreach ( $keys as $key ) {
121 if ( property_exists( $website, $key ) ) {
122 $outputSite[ $key ] = $website->$key;
123 }
124 }
125 } elseif ( is_array( $website ) ) {
126 foreach ( $keys as $key ) {
127 $outputSite[ $key ] = $website[ $key ];
128 }
129 }
130 }
131
132 if ( $object_output ) {
133 return (object) $outputSite;
134 } else {
135 return $outputSite;
136 }
137 }
138
139 /**
140 * Method array_sort()
141 *
142 * Sort given array by given flags.
143 *
144 * @param mixed $arr Array to sort.
145 * @param mixed $key Array key.
146 * @param string $sort_flag Flags to sort by. Default = SORT_STRING.
147 */
148 public static function array_sort( &$arr, $key, $sort_flag = SORT_STRING ) {
149 $sorter = array();
150 $ret = array();
151 reset( $arr );
152 foreach ( $arr as $ii => $val ) {
153 $sorter[ $ii ] = $val[ $key ];
154 }
155 asort( $sorter, $sort_flag );
156 foreach ( $sorter as $ii => $val ) {
157 $ret[ $ii ] = $arr[ $ii ];
158 }
159 $arr = $ret;
160 }
161
162 /**
163 * Debugging log info.
164 *
165 * Sets logging for debugging purpose
166 *
167 * @param string $message Log info message.
168 */
169 public static function log_info( $message ) {
170 static::log_debug( $message, 2 );
171 }
172
173 /**
174 * Debugging log.
175 *
176 * Sets logging for debugging purpose.
177 *
178 * @param string $message Log debug message.
179 * @param int $log_color Log color.
180 */
181 public static function log_debug( $message, $log_color = 3 ) {
182 if ( is_array( $message ) || is_object( $message ) ) {
183 $message = print_r( $message, true ); //phpcs:ignore
184 } elseif ( ! is_string( $message ) ) {
185 $message = 'undefined';
186 }
187
188 if ( ! in_array( $log_color, array( 0, 1, 2, 3 ) ) ) {
189 $log_color = 3;
190 }
191 do_action( 'mainwp_log_action', 'API Backups :: ' . $message, MainWP_Logger::API_BACKUPS_LOG_PRIORITY, $log_color );
192 }
193
194 /**
195 *
196 * Method save_lasttime_backup().
197 *
198 * @param int $site_id site id.
199 * @param int $available_backups Available backups.
200 * @param string $backup_api API backups provider.
201 *
202 * @return mixed
203 */
204 public static function save_lasttime_backup( $site_id, $available_backups, $backup_api ) { //phpcs:ignore -- NOSONAR - complex method.
205
206 static::log_debug( 'save backup time :: [available backups=' . ( is_string( $available_backups ) ? $available_backups : 'is not string' ) . ']' );
207
208 if ( empty( $available_backups ) ) {
209 return;
210 }
211
212 if ( is_string( $available_backups ) ) {
213 $available_backups = json_decode( $available_backups );
214 }
215
216 $primaryBackup = MainWP_System_Utility::get_primary_backup();
217
218 $website = Api_Backups_Helper::get_website_by_id( $site_id );
219
220 $backup_method = '';
221 if ( is_array( $website ) && isset( $website['primary_backup_method'] ) ) {
222 if ( '' === $website['primary_backup_method'] || 'global' === $website['primary_backup_method'] ) {
223 $backup_method = $primaryBackup;
224 } else {
225 $backup_method = $website['primary_backup_method'];
226 }
227 }
228
229 if ( 'module-api-backups' !== $backup_method ) {
230 return;
231 }
232
233 $lasttime_backup = 0;
234 if ( 'plesk' === $backup_api ) {
235 $available_backups = is_object( $available_backups ) && ! empty( $available_backups->value ) ? $available_backups->value : array();
236 if ( is_array( $available_backups ) ) {
237 foreach ( $available_backups as $backup ) {
238 if ( is_object( $backup ) && ! empty( $backup->value->createdAt->value ) ) {
239 $backup_time = strtotime( $backup->value->createdAt->value );
240 if ( $backup_time > $lasttime_backup ) {
241 $lasttime_backup = $backup_time;
242 }
243 }
244 }
245 }
246 } elseif ( 'kinsta' === $backup_api ) {
247 $available_backups = is_array( $available_backups ) && ! empty( $available_backups ) ? $available_backups : array();
248 if ( is_array( $available_backups ) ) {
249 foreach ( $available_backups as $backup ) {
250 if ( is_object( $backup ) && ! empty( $backup->created_at ) ) {
251 $milliseconds = $backup->created_at;
252 $epoch = $milliseconds / 1000;
253 $backup_time = strtotime( $epoch );
254 if ( $backup_time > $lasttime_backup ) {
255 $lasttime_backup = $backup_time;
256 }
257 }
258 }
259 }
260 } elseif ( 'cpanel_auto' === $backup_api ) {
261 if ( is_object( $available_backups ) && isset( $available_backups->data ) ) {
262 $available_backups_automatic_list = $available_backups->data;
263 } else {
264 $available_backups_automatic_list = array();
265 }
266
267 if ( is_array( $available_backups_automatic_list ) ) {
268 foreach ( $available_backups_automatic_list as $backup ) {
269 if ( is_object( $backup ) && ! empty( $backup->backupID ) ) {
270 $backup_time = strtotime( $backup->backupID );
271 if ( $backup_time > $lasttime_backup ) {
272 $lasttime_backup = $backup_time;
273 }
274 }
275 }
276 }
277 } elseif ( 'cpanel_manual' === $backup_api ) {
278 $available_backups_manual_list = $available_backups;
279 if ( is_array( $available_backups_manual_list ) ) {
280 foreach ( $available_backups_manual_list as $backup ) {
281 if ( is_object( $backup ) && ! empty( $backup->timestamp ) ) {
282 $backup_time = $backup->timestamp;
283 if ( $backup_time > $lasttime_backup ) {
284 $lasttime_backup = $backup_time;
285 }
286 }
287 }
288 }
289 } elseif ( 'cpanel_wp_toolkit' === $backup_api ) {
290 $available_backups_manual_list = $available_backups;
291 if ( is_array( $available_backups_manual_list ) ) {
292 foreach ( $available_backups_manual_list as $backup ) {
293 if ( is_object( $backup ) && ! empty( $backup->value->createdAt->value ) ) {
294 $backup_time = strtotime( $backup->value->createdAt->value );
295 if ( $backup_time > $lasttime_backup ) {
296 $lasttime_backup = $backup_time;
297 }
298 }
299 }
300 }
301 } elseif ( 'gridpane' === $backup_api ) {
302 if ( isset( $available_backups->automatic ) ) {
303 $available_backups_automatic_list = explode( ',', $available_backups->automatic );
304 } else {
305 $available_backups_automatic_list = array();
306 }
307 if ( isset( $available_backups->manual ) ) {
308 $available_backups_manual_list = explode( ',', $available_backups->manual );
309 } else {
310 $available_backups_manual_list = array();
311 }
312 // to do check date created: $api_response->backups->local.
313
314 if ( is_array( $available_backups_automatic_list ) ) {
315 foreach ( $available_backups_automatic_list as $backup_name ) {
316 $backup_time = substr( $backup_name, 0, 16 ); // get date time string in name.
317 $backup_time = strtotime( $backup_time );
318 if ( $backup_time > $lasttime_backup ) {
319 $lasttime_backup = $backup_time;
320 }
321 }
322 }
323
324 if ( is_array( $available_backups_manual_list ) ) {
325 foreach ( $available_backups_manual_list as $backup_name ) {
326 $backup_time = substr( $backup_name, 0, 16 ); // get date time string in name.
327 $backup_time = strtotime( $backup_time );
328 if ( $backup_time > $lasttime_backup ) {
329 $lasttime_backup = $backup_time;
330 }
331 }
332 }
333 } elseif ( 'cloudways' === $backup_api ) {
334 if ( isset( $available_backups->application_backup_exists ) && true === $available_backups->application_backup_exists ) {
335 $available_backups = $available_backups->backup_dates;
336 } else {
337 $available_backups = array();
338 }
339
340 if ( is_array( $available_backups ) ) {
341 foreach ( $available_backups as $backup ) {
342 $backup_time = strtotime( $backup );
343 if ( $backup_time > $lasttime_backup ) {
344 $lasttime_backup = $backup_time;
345 }
346 }
347 }
348 } elseif ( 'vultr' === $backup_api ) {
349 if ( isset( $available_backups->snapshots ) ) {
350 $available_snapshots_list = $available_backups->snapshots;
351 } else {
352 $available_snapshots_list = array();
353 }
354 if ( isset( $available_backups->backups ) ) {
355 $available_backups_list = $available_backups->backups;
356 } else {
357 $available_backups_list = array();
358 }
359 if ( is_array( $available_snapshots_list ) ) {
360 foreach ( $available_snapshots_list as $backup ) {
361 if ( is_object( $backup ) && ! empty( $backup->date_created ) ) {
362 $backup_time = strtotime( $backup->date_created );
363 if ( $backup_time > $lasttime_backup ) {
364 $lasttime_backup = $backup_time;
365 }
366 }
367 }
368 }
369 if ( is_array( $available_backups_list ) ) {
370 foreach ( $available_backups_list as $backup ) {
371 if ( is_object( $backup ) && ! empty( $backup->date_created ) ) {
372 $backup_time = strtotime( $backup->date_created );
373 if ( $backup_time > $lasttime_backup ) {
374 $lasttime_backup = $backup_time;
375 }
376 }
377 }
378 }
379 } elseif ( 'linode' === $backup_api ) {
380 // Automatic Backups.
381 if ( isset( $available_backups->automatic ) ) {
382 $available_backups_automatic_list = $available_backups->automatic;
383 } else {
384 $available_backups_automatic_list = array();
385 }
386 // Manual Backups.
387 if ( isset( $available_backups->snapshot ) ) {
388 $available_backups_snapshot_list = $available_backups->snapshot;
389 } else {
390 $available_backups_snapshot_list = array();
391 }
392 if ( is_array( $available_backups_automatic_list ) ) {
393 foreach ( $available_backups_automatic_list as $backup ) {
394 if ( is_object( $backup ) && ! empty( $backup->created ) ) {
395 $backup_time = strtotime( $backup->created );
396 if ( $backup_time > $lasttime_backup ) {
397 $lasttime_backup = $backup_time;
398 }
399 }
400 }
401 }
402 if ( is_array( $available_backups_snapshot_list ) ) {
403 foreach ( $available_backups_snapshot_list as $backup ) {
404 if ( is_object( $backup ) && ! empty( $backup->created ) ) {
405 $backup_time = strtotime( $backup->created );
406 if ( $backup_time > $lasttime_backup ) {
407 $lasttime_backup = $backup_time;
408 }
409 }
410 }
411 }
412 } elseif ( 'digitalocean' === $backup_api ) {
413 if ( isset( $available_backups->snapshots ) ) {
414 $available_backups = $available_backups->snapshots;
415 }
416 if ( is_array( $available_backups ) ) {
417 foreach ( $available_backups as $backup ) {
418 if ( is_object( $backup ) && ! empty( $backup->created_at ) ) {
419 $backup_time = strtotime( $backup->created_at );
420 if ( $backup_time > $lasttime_backup ) {
421 $lasttime_backup = $backup_time;
422 }
423 }
424 }
425 }
426 }
427
428 if ( empty( $lasttime_backup ) ) {
429 return;
430 }
431 $lastBackup = MainWP_DB::instance()->get_website_option( $site_id, 'primary_lasttime_backup' );
432
433 if ( ! empty( $lastBackup ) && $lastBackup > $lasttime_backup ) {
434 return;
435 }
436 static::log_debug( 'save backup time :: [site-id=' . $site_id . '] :: [backup time=' . gmdate( 'Y-m-d H:i:s', $lasttime_backup ) . '] :: [api-backups=' . $backup_api . ']' );
437 $site = new \stdClass();
438 $site->id = $site_id;
439 MainWP_DB::instance()->update_website_option( $site, 'primary_lasttime_backup', $lasttime_backup );
440 }
441
442 /**
443 * Show Info Messages
444 *
445 * Check whenther or not to show the MainWP Message.
446 *
447 * @param string $notice_id Notice ID.
448 *
449 * @return bool False if hidden, true to show.
450 */
451 public static function show_mainwp_message( $notice_id ) {
452 $status = get_user_option( 'mainwp_notice_saved_status' );
453 if ( ! is_array( $status ) ) {
454 $status = array();
455 }
456 if ( isset( $status[ $notice_id ] ) ) {
457 return false;
458 }
459 return true;
460 }
461
462
463 /**
464 * Method human_filesize()
465 *
466 * Convert to human readable file size format,
467 * (B|kB|MB|GB|TB|PB|EB|ZB|YB).
468 *
469 * @param mixed $bytes File in bytes.
470 * @param integer $decimals Number of decimals to output.
471 *
472 * @return string Human readable file size.
473 */
474 public static function human_filesize( $bytes, $decimals = 2 ) {
475 $size = array( 'B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' );
476 $factor = floor( ( strlen( $bytes ) - 1 ) / 3 );
477
478 return sprintf( "%.{$decimals}f", $bytes / pow( 1024, $factor ) ) . @$size[ $factor ]; //phpcs:ignore
479 }
480
481
482 /**
483 * Get Color Code
484 *
485 * Returns CSS class to use correct color for the element.
486 *
487 * @param int $value value.
488 *
489 * @return string CSS class.
490 */
491 public static function color_code( $value ) {
492 $color = '';
493 if ( 5 < $value ) {
494 $color = 'red';
495 } elseif ( 0 < $value && 5 >= $value ) {
496 $color = 'yellow';
497 } else {
498 $color = 'green';
499 }
500 return $color;
501 }
502
503 /**
504 * Method update_option()
505 *
506 * Update option.
507 *
508 * @param mixed $option_name Option name.
509 * @param mixed $option_value Option value.
510 *
511 * @return (boolean) False if value was not updated and true if value was updated.
512 */
513 public static function update_option( $option_name, $option_value ) {
514 $success = add_option( $option_name, $option_value, '', 'no' );
515
516 if ( ! $success ) {
517 $success = update_option( $option_name, $option_value );
518 }
519
520 return $success;
521 }
522
523
524 /**
525 * Method encrypt_api_keys
526 *
527 * @param string $data data.
528 * @param int $siteid site id.
529 * @param string $file_key file key.
530 * @param string $service_name service name.
531 *
532 * Encrypt data.
533 */
534 public function encrypt_api_keys( $data, $siteid = false, $file_key = false, $service_name = '' ) {
535 if ( is_string( $data ) ) {
536
537 $prefix = 'apibackups_';
538
539 if ( ! empty( $siteid ) ) {
540 $prefix = $prefix . intval( $siteid ) . '_';
541 }
542
543 if ( ! empty( $service_name ) && is_string( $service_name ) ) {
544 $prefix = $prefix . $service_name . '_';
545 }
546
547 $result = apply_filters( 'mainwp_encrypt_key_value', false, $data, $prefix, $file_key );
548
549 if ( is_array( $result ) && ! empty( $result['encrypted_val'] ) ) {
550 return $result;
551 }
552 }
553 return $data;
554 }
555
556 /**
557 * Method decrypt_api_keys
558 *
559 * @param mixed $encrypted_data encrypted data.
560 * @param string $def_val default data.
561 */
562 public function decrypt_api_keys( $encrypted_data, $def_val = '' ) {
563 if ( ! empty( $encrypted_data ) && is_array( $encrypted_data ) && ! empty( $encrypted_data['encrypted_val'] ) ) { // old format.
564 $result = apply_filters( 'mainwp_decrypt_key_value', false, $encrypted_data, $def_val );
565 if ( ! empty( $result ) && is_string( $result ) ) {
566 return $result;
567 }
568 }
569 return $def_val;
570 }
571
572 /**
573 * Method get_compatible_site_api_key
574 *
575 * Encrypt data.
576 *
577 * @param string $name name data.
578 * @param string $def_val default data.
579 */
580 public function get_api_key( $name, $def_val = '' ) {
581
582 $names = array(
583 'vultr',
584 'gridpane',
585 'linode',
586 'digitalocean',
587 'cloudways',
588 'cpanel',
589 'plesk',
590 'kinsta',
591 );
592
593 if ( ! in_array( $name, $names ) ) {
594 return $def_val;
595 }
596
597 $encrypted = get_option( 'mainwp_api_backups_' . $name . '_api_key' );
598 if ( is_array( $encrypted ) && ! empty( $encrypted['file_key'] ) ) {
599 $key = $this->decrypt_api_keys( $encrypted );
600 if ( ! empty( $key ) && is_string( $key ) ) {
601 return $key;
602 }
603 }
604 return $def_val;
605 }
606
607 /**
608 * Method update_compatible_site_api_key
609 *
610 * Encrypt data.
611 *
612 * @param string $name name data.
613 * @param string $value value data.
614 */
615 public function update_api_key( $name, $value ) {
616
617 $names = array(
618 'vultr',
619 'gridpane',
620 'linode',
621 'digitalocean',
622 'cloudways',
623 'cpanel',
624 'plesk',
625 'kinsta',
626 );
627
628 if ( ! in_array( $name, $names ) ) {
629 return false;
630 }
631
632 $opt_name = 'mainwp_api_backups_' . $name . '_api_key';
633 $current = get_option( $opt_name );
634 $key_file = '';
635
636 if ( is_array( $current ) && ! empty( $current['file_key'] ) ) {
637 $key_file = $current['file_key'];
638 }
639
640 if ( empty( $value ) ) {
641 delete_option( $opt_name );
642 if ( ! empty( $key_file ) ) {
643 do_action( 'mainwp_delete_key_file', $key_file );
644 }
645 return true;
646 }
647
648 $encrypted = $this->encrypt_api_keys( $value, false, $key_file, $name );
649 if ( is_array( $encrypted ) && ! empty( $encrypted['file_key'] ) ) {
650 return update_option( $opt_name, $encrypted );
651 }
652
653 return false;
654 }
655
656 /**
657 * Method get child site key.
658 *
659 * Encrypt data.
660 *
661 * @param int $website_id name data.
662 * @param string $name name data.
663 * @param string $def_val default data.
664 */
665 public function get_child_api_key( $website_id, $name, $def_val = '' ) {
666
667 $names = array(
668 'vultr',
669 'gridpane',
670 'linode',
671 'digitalocean',
672 'cloudways',
673 'cpanel',
674 'plesk',
675 'kinsta',
676 );
677
678 if ( ! in_array( $name, $names ) ) {
679 return $def_val;
680 }
681
682 $opt_name = 'mainwp_api_backups_' . $name . '_api_key';
683 $opt_encoded = Api_Backups_Helper::get_website_options( $website_id, array( $opt_name ) );
684 if ( array_key_exists( $opt_name, $opt_encoded ) ) {
685 $encrypted = json_decode( $opt_encoded[ $opt_name ], true );
686 } else {
687 $encrypted = '';
688 }
689
690 if ( is_array( $encrypted ) && ! empty( $encrypted['file_key'] ) ) {
691 $key = $this->decrypt_api_keys( $encrypted );
692
693 if ( ! empty( $key ) && is_string( $key ) ) {
694 return $key;
695 }
696 }
697 return $def_val;
698 }
699
700 /**
701 * Method update child api key.
702 *
703 * Encrypt data.
704 *
705 * @param int $website_id name data.
706 * @param string $name name data.
707 * @param string $value value data.
708 */
709 public function update_child_api_key( $website_id, $name, $value ) {
710
711 $names = array(
712 'vultr',
713 'gridpane',
714 'linode',
715 'digitalocean',
716 'cloudways',
717 'cpanel',
718 'plesk',
719 'kinsta',
720 );
721
722 if ( ! in_array( $name, $names ) ) {
723 return false;
724 }
725
726 $opt_name = 'mainwp_api_backups_' . $name . '_api_key';
727 $opt_encoded = Api_Backups_Helper::get_website_options( $website_id, array( $opt_name ) );
728 if ( array_key_exists( $opt_name, $opt_encoded ) ) {
729 $current = json_decode( $opt_encoded[ $opt_name ], true );
730 } else {
731 $current = '';
732 }
733 $key_file = '';
734 if ( is_array( $current ) && ! empty( $current['file_key'] ) ) {
735 $key_file = $current['file_key'];
736 }
737
738 // If post $value is empty, delete option.
739 if ( empty( $value ) ) {
740 delete_option( $opt_name );
741 if ( ! empty( $key_file ) ) {
742 do_action( 'mainwp_delete_key_file', $key_file );
743 }
744 return true;
745 }
746
747 $encrypted = wp_json_encode( $this->encrypt_api_keys( $value, $website_id, $key_file, $name ) );
748
749 if ( ! empty( $encrypted ) ) {
750 return Api_Backups_Helper::update_website_option( $website_id, $opt_name, $encrypted );
751 }
752
753 return false;
754 }
755 }
756