From a4a25bc9b51c621ff0e0ded2471be73fb4ee15cc Mon Sep 17 00:00:00 2001 From: namithj <48271037+namithj@users.noreply.github.com> Date: Mon, 4 Nov 2024 02:33:43 +0530 Subject: [PATCH] Warning when debug-aspire-update.log doesnt exist Fixes #57 --- includes/class-debug.php | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/includes/class-debug.php b/includes/class-debug.php index ee6a7e4..21e07f5 100644 --- a/includes/class-debug.php +++ b/includes/class-debug.php @@ -71,20 +71,16 @@ public static function log( $message, $type = 'string' ) { $file_path = WP_CONTENT_DIR . '/' . self::$log_file; - $content = $wp_filesystem->get_contents( $file_path ); - if ( false === $content ) { - $wp_filesystem->put_contents( - $file_path, - $formatted_message, - FS_CHMOD_FILE - ); - } else { - $wp_filesystem->put_contents( - $file_path, - $content . $formatted_message, - FS_CHMOD_FILE - ); + $content = ''; + if ( $wp_filesystem->exists( $file_path ) ) { + $content = $wp_filesystem->get_contents( $file_path ); } + + $wp_filesystem->put_contents( + $file_path, + $content . $formatted_message, + FS_CHMOD_FILE + ); } /**