Skip to content

Commit

Permalink
Improved the function to restore all files
Browse files Browse the repository at this point in the history
  • Loading branch information
teamcrombie committed Jul 16, 2024
1 parent e2dfd4b commit b8ba377
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions admin/Ilove_Img_Wm_Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,21 +158,16 @@ public function ilove_img_wm_library() {
public function ilove_img_wm_restore_all() {

if ( is_dir( ILOVE_IMG_WM_BACKUP_FOLDER ) ) {
$folders = array_diff( scandir( ILOVE_IMG_WM_BACKUP_FOLDER ), array( '..', '.' ) );

foreach ( $folders as $key => $folder ) {
Ilove_Img_Wm_Resources::rcopy( ILOVE_IMG_WM_BACKUP_FOLDER . $folder, ILOVE_IMG_WM_UPLOAD_FOLDER . '/' . $folder );
}

Ilove_Img_Wm_Resources::rrmdir( ILOVE_IMG_WM_BACKUP_FOLDER );

$images_restore = json_decode( get_option( 'iloveimg_images_to_restore' ), true );

foreach ( $images_restore as $key => $value ) {
Ilove_Img_Wm_Resources::rcopy( ILOVE_IMG_WM_BACKUP_FOLDER . basename( get_attached_file( $value ) ), get_attached_file( $value ) );

delete_post_meta( $value, 'iloveimg_status_watermark' );
delete_post_meta( $value, 'iloveimg_watermark' );
delete_post_meta( $value, 'iloveimg_status_compress' );
delete_post_meta( $value, 'iloveimg_compress' );
wp_delete_file( ILOVE_IMG_WM_BACKUP_FOLDER . basename( get_attached_file( $value ) ) );
delete_option( 'iloveimg_images_to_restore' );
}
}
Expand Down

0 comments on commit b8ba377

Please sign in to comment.