Skip to content

Commit 59b8e20

Browse files
authored
Updates
1 parent c944161 commit 59b8e20

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

simple-wp-site-exporter.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,16 @@ function sse_setup_export_directories() {
427427
return new WP_Error( 'export_dir_creation_failed', __( 'Could not create the export directory. Please verify filesystem permissions.', 'simple-wp-site-exporter' ) );
428428
}
429429

430-
$is_writable = function_exists( 'wp_is_writable' ) ? wp_is_writable( $export_dir ) : is_writable( $export_dir ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_is_writable
431-
if ( ! $is_writable ) {
430+
global $wp_filesystem;
431+
if ( ! $wp_filesystem ) {
432+
require_once ABSPATH . 'wp-admin/includes/file.php';
433+
if ( ! WP_Filesystem() ) {
434+
sse_log( 'Failed to initialize WordPress filesystem API', 'error' );
435+
return new WP_Error( 'filesystem_init_failed', __( 'Failed to initialize WordPress filesystem API.', 'simple-wp-site-exporter' ) );
436+
}
437+
}
438+
439+
if ( ! $wp_filesystem->is_writable( $export_dir ) ) {
432440
sse_log( 'Export directory is not writable: ' . $export_dir, 'error' );
433441
return new WP_Error( 'export_dir_not_writable', __( 'The export directory is not writable. Please adjust filesystem permissions.', 'simple-wp-site-exporter' ) );
434442
}

0 commit comments

Comments
 (0)