Skip to content

Commit

Permalink
Add rename optimisation methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Jan 19, 2024
1 parent 771c011 commit 956726a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions classes/Optimization/Process/AbstractProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function optimize( $optimization_level = null, $args = [] ) {
if ( $data->is_already_optimized() && $this->has_webp() ) {
// If already optimized but has WebP, delete WebP versions and optimization data.
$data->delete_optimization_data();
$deleted = $this->delete_webp_files();
$deleted = $this->delete_nextgen_files();

if ( is_wp_error( $deleted ) ) {
return new WP_Error( 'webp_not_deleted', __( 'Previous WebP files could not be deleted.', 'imagify' ) );
Expand Down Expand Up @@ -935,7 +935,7 @@ protected function restore_thumbnails() {
* In that case we must also delete the WebP file associated to the full size.
*/
$keep_full_webp = $media->get_raw_original_path() === $media->get_raw_fullsize_path();
$this->delete_webp_files( $keep_full_webp );
$this->delete_nextgen_files( $keep_full_webp );

// Generate new thumbnails.
return $media->generate_thumbnails();
Expand Down Expand Up @@ -1321,7 +1321,7 @@ protected function can_backup( $size ) {
*
* @return bool|WP_Error True if successfully launched. A \WP_Error instance on failure.
*/
public function generate_webp_versions() {
public function generate_nextgen_versions() {
if ( ! $this->is_valid() ) {
return new WP_Error( 'invalid_media', __( 'This media is not valid.', 'imagify' ) );
}
Expand Down Expand Up @@ -1349,7 +1349,7 @@ public function generate_webp_versions() {
$files = $media->get_media_files();
$sizes = [];
$args = [
'hook_suffix' => 'generate_webp_versions',
'hook_suffix' => 'generate_nextgen_versions',
];

foreach ( $files as $size_name => $file ) {
Expand Down Expand Up @@ -1378,7 +1378,7 @@ public function generate_webp_versions() {
* @param bool $keep_full Set to true to keep the full size.
* @return bool|WP_Error True on success. A \WP_Error object on failure.
*/
public function delete_webp_files( $keep_full = false ) {
public function delete_nextgen_files( $keep_full = false ) {
if ( ! $this->is_valid() ) {
return new WP_Error( 'invalid_media', __( 'This media is not valid.', 'imagify' ) );
}
Expand Down
6 changes: 3 additions & 3 deletions classes/Optimization/Process/Noop.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,15 @@ public function maybe_resize( $size, $file ) {
/** ----------------------------------------------------------------------------------------- */

/**
* Generate WebP images if they are missing.
* Generate Nextgen images if they are missing.
*
* @since 1.9
* @access public
* @author Grégory Viguier
*
* @return bool|WP_Error True if successfully launched. A \WP_Error instance on failure.
*/
public function generate_webp_versions() {
public function generate_nextgen_versions() {
return new \WP_Error( 'invalid_media', __( 'This media is not valid.', 'imagify' ) );
}

Expand All @@ -306,7 +306,7 @@ public function generate_webp_versions() {
* @access public
* @author Grégory Viguier
*/
public function delete_webp_files() {}
public function delete_nextgen_files() {}

/**
* Tell if a thumbnail size is an "Imagify WebP" size.
Expand Down
4 changes: 2 additions & 2 deletions classes/Optimization/Process/ProcessInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public function maybe_resize( $size, $file );
*
* @return bool|WP_Error True if successfully launched. A \WP_Error instance on failure.
*/
public function generate_webp_versions();
public function generate_nextgen_versions();

/**
* Delete the WebP images.
Expand All @@ -260,7 +260,7 @@ public function generate_webp_versions();
* @param bool $keep_full Set to true to keep the full size.
* @return bool|\WP_Error True on success. A \WP_Error object on failure.
*/
public function delete_webp_files( $keep_full = false );
public function delete_nextgen_files( $keep_full = false );

/**
* Tell if a thumbnail size is an "Imagify WebP" size.
Expand Down
2 changes: 1 addition & 1 deletion inc/3rd-party/nextgen-gallery/inc/common/attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function imagify_ngg_cleanup_after_media_deletion( $image_id, $image ) {
* The backup file has already been deleted by NGG.
* Delete the WebP versions and the optimization data.
*/
$process->delete_webp_files();
$process->delete_nextgen_files();
$process->get_data()->delete_optimization_data();
}

Expand Down
4 changes: 2 additions & 2 deletions inc/classes/class-imagify-admin-ajax-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ protected function optimize_missing_sizes( $media_id, $context ) {
* @return bool|WP_Error True if successfully launched. A \WP_Error instance on failure.
*/
protected function generate_nextgen_versions( $media_id, $context ) {
return imagify_get_optimization_process( $media_id, $context )->generate_webp_versions();
return imagify_get_optimization_process( $media_id, $context )->generate_nextgen_versions();
}

/**
Expand Down Expand Up @@ -233,7 +233,7 @@ protected function delete_nextgen_versions( $media_id, $context ) {
}

$data->delete_optimization_data();
$deleted = $process->delete_webp_files();
$deleted = $process->delete_nextgen_files();

if ( is_wp_error( $deleted ) ) {
return new WP_Error( 'webp_not_deleted', __( 'Previous WebP files could not be deleted.', 'imagify' ) );
Expand Down
4 changes: 2 additions & 2 deletions inc/common/attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ function imagify_cleanup_after_media_deletion( $process ) {

/**
* The optimization data will be automatically deleted by WP (post metas).
* Delete the WebP versions and the backup file.
* Delete the Nextgen versions and the backup file.
*/
$process->delete_webp_files();
$process->delete_nextgen_files();
$process->delete_backup();
}

Expand Down

0 comments on commit 956726a

Please sign in to comment.