PluginProbe
WP Database Backup – Unlimited Database & Files Backup by Backup for WP / 7.12
WP Database Backup – Unlimited Database & Files Backup by Backup for WP v7.12
7.13 7.12 trunk 1.1 2.1.1 5.9 6.0 6.1 6.10 6.11 6.12 6.12.1 6.2 6.3 6.4 6.5 6.5.1 6.6 6.7 6.8 6.9 7.0 7.0.1 7.1 7.10 All 34 releases
wp-database-backup / includes / class-wpdbfullbackuplog.php

class-wpdbfullbackuplog.php in WP Database Backup – Unlimited Database & Files Backup by Backup for WP 7.12, at includes/class-wpdbfullbackuplog.php

67 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5 add_action( 'wpdbbkp_backup_completed', array( 'WPDBFullBackupLog', 'wpdbbkp_backup_completed' ), 11 );
6
7 /**
8 * Class WPDBFullBackupLog
9 *
10 * Handles logging and updating backup completion details.
11 */
12 class WPDBFullBackupLog {
13
14 /**
15 * Processes backup completion details and updates options.
16 *
17 * @param array $args Backup completion arguments.
18 */
19 public static function wpdbbkp_backup_completed( &$args ) {
20 global $wp_filesystem;
21
22 // Ensure WP Filesystem is loaded
23 if ( ! function_exists( 'WP_Filesystem' ) ) {
24 require_once ABSPATH . 'wp-admin/includes/file.php';
25 }
26 WP_Filesystem();
27
28 // Retrieve existing options
29 $options = get_option( 'wp_db_backup_backups' );
30 $new_options = array();
31
32 if ( ! empty( $options ) && is_array( $options ) ) {
33 foreach ( $options as $option ) {
34 if ( ! is_array( $option ) ) {
35 continue;
36 }
37 if ( $option['filename'] === $args[0] ) {
38 $option['destination'] = wp_kses( $args[4], wp_kses_allowed_html( 'post' ) );
39 }
40 $new_options[] = $option;
41 }
42 }
43
44 $new_options = wpdbbkp_filter_unique_filenames( $new_options );
45
46 // Update the options
47 update_option( 'wp_db_backup_backups', $new_options, false );
48
49 // Log to file if logging is enabled
50 if ( get_option( 'wp_db_log' ) == 1 ) {
51 if ( isset( $args[5] ) && ! empty( $args[5] ) ) {
52 if ( $wp_filesystem->is_writable( $args[5] ) || ! $wp_filesystem->exists( $args[5] ) ) {
53 $log_content = str_replace( '<br>', "\n", $args[2] );
54
55 // Append to the log file
56 if ( false === $wp_filesystem->put_contents( $args[5], $log_content, FS_APPEND ) ) {
57 // Handle the error if needed
58 return false;
59 }
60
61 return true;
62 }
63 }
64 }
65 }
66 }
67