PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.14.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.14.0
2.14.0 2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 81 releases
← All changes | includes/classes/file-upload.php +15 -10 2.9.1 → 2.14.0 View file →
@@ -119,10 +119,15 @@
119 119 if ( empty( $wp_filesystem ) ) {
120 120 require_once ABSPATH . '/wp-admin/includes/file.php';
121 121 WP_Filesystem();
122 122 }
123 - if ( is_dir( $file_name ) ) {
124 - return $wp_filesystem->rmdir( $file_name, true );
123 + $upload_dir = $this->get_upload_dir();
124 + $file_path = $upload_dir . '/' . $file_name;
125 +
126 + if ( $wp_filesystem->is_file( $file_path ) ) {
127 + return $wp_filesystem->delete( $file_path );
128 + } elseif ( $wp_filesystem->is_dir( $file_path ) ) {
129 + return $wp_filesystem->rmdir( $file_path, true );
125 130 }
126 131 return false;
127 132 }
128 133 public function delete_files() {
@@ -135,17 +140,17 @@
135 140 $upload_dir = $this->get_upload_dir();
136 141
137 142 // Get all files in the directory
138 143 $files = $wp_filesystem->dirlist( $upload_dir );
139 -
140 - foreach ( $files as $file => $fileinfo ) {
141 - $file_path = $upload_dir . '/' . $file;
142 - if ( $wp_filesystem->is_file( $file_path ) ) {
143 - $wp_filesystem->delete( $file_path );
144 - } elseif ( $wp_filesystem->is_dir( $file_path ) ) {
145 - $wp_filesystem->rmdir( $file_path, true );
144 + if ( is_array( $files ) && count( $files ) ) {
145 + foreach ( $files as $file => $fileinfo ) {
146 + $file_path = $upload_dir . '/' . $file;
147 + if ( $wp_filesystem->is_file( $file_path ) ) {
148 + $wp_filesystem->delete( $file_path );
149 + } elseif ( $wp_filesystem->is_dir( $file_path ) ) {
150 + $wp_filesystem->rmdir( $file_path, true );
151 + }
146 152 }
147 153 }
148 -
149 154 return true;
150 155 }
151 156 }