From c3ca99863b08e724a7a55675d5932c26095dd0ce Mon Sep 17 00:00:00 2001 From: Namith Jawahar <48271037+namithj@users.noreply.github.com> Date: Mon, 4 Nov 2024 03:34:52 +0530 Subject: [PATCH] Warning when debug-aspire-update.log doesnt exist (#109) --- 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 + ); } /**