| @@ -11,8 +11,9 @@ | ||
| 11 | 11 | use ReflectionClass; |
| 12 | 12 | use ReflectionMethod; |
| 13 | 13 | use ReflectionProperty; |
| 14 | 14 | use Calotes\Component\Behavior; |
| 15 | +use WP_Filesystem_Base; | |
| 15 | 16 | |
| 16 | 17 | /** |
| 17 | 18 | * Base class for all components. |
| 18 | 19 | */ |
| @@ -268,9 +269,9 @@ | ||
| 268 | 269 | */ |
| 269 | 270 | protected function log( $message, $category = '' ): void { |
| 270 | 271 | global $wp_filesystem; |
| 271 | 272 | // Initialize the WP filesystem, no more using 'file-put-contents' function. |
| 272 | - if ( empty( $wp_filesystem ) ) { | |
| 273 | + if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) { | |
| 273 | 274 | require_once ABSPATH . '/wp-admin/includes/file.php'; |
| 274 | 275 | WP_Filesystem(); |
| 275 | 276 | } |
| 276 | 277 | if ( ! is_string( $message ) || is_array( $message ) || is_object( $message ) ) { |
| @@ -286,9 +287,9 @@ | ||
| 286 | 287 | */ |
| 287 | 288 | $message = '[' . wp_date( 'c' ) . '] ' . $message . PHP_EOL; |
| 288 | 289 | |
| 289 | 290 | if ( $this->has_method( 'get_log_path' ) ) { |
| 290 | - if ( ! empty( $category ) && 0 === preg_match( '/\.log$/', $category ) ) { | |
| 291 | + if ( '' !== $category && 0 === preg_match( '/\.log$/', $category ) ) { | |
| 291 | 292 | $category .= '.log'; |
| 292 | 293 | } |
| 293 | 294 | |
| 294 | 295 | $file_path = $this->get_log_path( $category ); |