Skip to content

Commit 3fab05b

Browse files
author
Md. Alimuzzaman Alim
committed
Shortpixel improvement #254
1 parent c699490 commit 3fab05b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/classes/compatibility/shortpixel.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class ShortPixel extends ICompatibility {
2222
public function module_init($sm){
2323
add_action( 'shortpixel_image_optimised', array($this, 'shortpixel_image_optimised') );
2424
add_filter( 'get_attached_file', array($this, 'fix_missing_file'), 10, 2 );
25-
add_action( 'admin_action_shortpixel_restore_backup', array($this, 'handleRestoreBackup'), 999 );
25+
add_action( 'shortpixel_before_restore_image', array($this, 'sync_backup_file') );
26+
add_action( 'shortpixel_after_restore_image', array($this, 'handleRestoreBackup') );
2627
add_action( 'admin_enqueue_scripts', array( $this, 'shortPixelJS') );
2728
// Sync from sync tab
2829
add_action( 'sm:synced::image', array( $this, 'sync_backup_file'), 10, 2 );
@@ -141,7 +142,7 @@ public function shortpixel_image_optimised($id){
141142
/**
142143
* Sync backup image
143144
*/
144-
public function sync_backup_file($id, $metadata){
145+
public function sync_backup_file($id, $metadata = null){
145146

146147
/* Get metadata in case if method is called directly. */
147148
if( empty($metadata) ) {
@@ -211,8 +212,7 @@ public function returnSubDir($file){
211212
/**
212213
* Sync images after shortpixel restore them from backup.
213214
*/
214-
public function handleRestoreBackup(){
215-
$attachmentID = intval($_GET['attachment_ID']);
215+
public function handleRestoreBackup($attachmentID){
216216
$metadata = wp_get_attachment_metadata( $attachmentID );
217217
$this->add_media( $metadata, $attachmentID );
218218
}

0 commit comments

Comments
 (0)