Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change methods name #785

Merged
merged 4 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions inc/classes/class-imagify-admin-ajax-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
'imagify_manual_optimize',
'imagify_manual_reoptimize',
'imagify_optimize_missing_sizes',
'imagify_generate_webp_versions',
'imagify_delete_webp_versions',
'imagify_generate_nextgen_versions',
Copy link
Contributor

@Miraeld Miraeld Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ this function has been refactored here with a different name :

'imagify_generate_next_gen_versions',

'imagify_delete_nextgen_versions',
'imagify_restore',
// Custom folders optimization.
'imagify_optimize_file',
Expand Down Expand Up @@ -202,20 +202,20 @@ protected function optimize_missing_sizes( $media_id, $context ) {
* @param string $context The context.
* @return bool|WP_Error True if successfully launched. A \WP_Error instance on failure.
*/
protected function generate_webp_versions( $media_id, $context ) {
protected function generate_nextgen_versions( $media_id, $context ) {
Copy link
Contributor

@Miraeld Miraeld Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ this function has been refactored here with a different name :

protected function generate_next_gen_versions( $media_id, $context ) {

return imagify_get_optimization_process( $media_id, $context )->generate_webp_versions();
}

/**
* Delete WebP images for media that are "already_optimize".
* Delete Next gen images for media that are "already_optimize".
*
* @since 1.9.6
*
* @param int $media_id The media ID.
* @param string $context The context.
* @return bool|WP_Error True if successfully launched. A \WP_Error instance on failure.
*/
protected function delete_webp_versions( $media_id, $context ) {
protected function delete_nextgen_versions( $media_id, $context ) {
$process = imagify_get_optimization_process( $media_id, $context );

if ( ! $process->is_valid() ) {
Expand Down Expand Up @@ -363,21 +363,21 @@ public function imagify_optimize_missing_sizes_callback() {
*
* @since 1.9
*/
public function imagify_generate_webp_versions_callback() {
public function imagify_generate_nextgen_versions_callback() {
Copy link
Contributor

@Miraeld Miraeld Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ this function has been refactored here with a different name :

public function imagify_generate_next_gen_versions_callback() {

$context = $this->get_context();
$media_id = $this->get_media_id();

if ( ! $media_id || ! $context ) {
imagify_die( __( 'Invalid request', 'imagify' ) );
}

imagify_check_nonce( 'imagify-generate-webp-versions-' . $media_id . '-' . $context );
imagify_check_nonce( 'imagify-generate-nextgen-versions-' . $media_id . '-' . $context );

if ( ! imagify_get_context( $context )->current_user_can( 'manual-optimize', $media_id ) ) {
imagify_die();
}

$result = $this->generate_webp_versions( $media_id, $context );
$result = $this->generate_nextgen_versions( $media_id, $context );

imagify_maybe_redirect( is_wp_error( $result ) ? $result : false );

Expand All @@ -396,21 +396,21 @@ public function imagify_generate_webp_versions_callback() {
*
* @since 1.9.6
*/
public function imagify_delete_webp_versions_callback() {
public function imagify_delete_nextgen_versions_callback() {
$context = $this->get_context();
$media_id = $this->get_media_id();

if ( ! $media_id || ! $context ) {
imagify_die( __( 'Invalid request', 'imagify' ) );
}

imagify_check_nonce( 'imagify-delete-webp-versions-' . $media_id . '-' . $context );
imagify_check_nonce( 'imagify-delete-nextgen-versions-' . $media_id . '-' . $context );

if ( ! imagify_get_context( $context )->current_user_can( 'manual-restore', $media_id ) ) {
imagify_die();
}

$result = $this->delete_webp_versions( $media_id, $context );
$result = $this->delete_nextgen_versions( $media_id, $context );

imagify_maybe_redirect( is_wp_error( $result ) ? $result : false );

Expand Down
6 changes: 3 additions & 3 deletions inc/classes/class-imagify-files-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ public function column_actions( $item ) {
$this->optimize_button( $item );
$this->retry_button( $item );
$this->reoptimize_buttons( $item );
$this->generate_webp_versions_button( $item );
$this->generate_nextgen_versions_button( $item );
$this->delete_webp_versions_button( $item );
$this->restore_button( $item );
}
Expand Down Expand Up @@ -806,13 +806,13 @@ protected function reoptimize_buttons( $item ) {
}

/**
* Prints a button to generate WebP versions if they are missing.
* Prints a button to generate Next gen versions if they are missing.
*
* @since 1.7
*
* @param object $item The current item. It must contain at least a $process property.
*/
protected function generate_webp_versions_button( $item ) {
protected function generate_nextgen_versions_button( $item ) {
Copy link
Contributor

@Miraeld Miraeld Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ this function has been refactored here with a different name :

protected function generate_next_gen_versions_button( $item ) {

$button = get_imagify_attachment_generate_webp_versions_link( $item->process );

if ( $button ) {
Expand Down
8 changes: 4 additions & 4 deletions inc/functions/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ function get_imagify_admin_url( $action = 'settings', $arg = [] ) {
case 'optimize-missing-sizes':
return wp_nonce_url( admin_url( 'admin-post.php?action=imagify_optimize_missing_sizes&attachment_id=' . $id . '&context=' . $context ), 'imagify-optimize-missing-sizes-' . $id . '-' . $context );

case 'generate-webp-versions':
return wp_nonce_url( admin_url( 'admin-post.php?action=imagify_generate_webp_versions&attachment_id=' . $id . '&context=' . $context ), 'imagify-generate-webp-versions-' . $id . '-' . $context );
case 'generate-nextgen-versions':
return wp_nonce_url( admin_url( 'admin-post.php?action=imagify_generate_nextgen_versions&attachment_id=' . $id . '&context=' . $context ), 'imagify-generate-nextgen-versions-' . $id . '-' . $context );

case 'delete-webp-versions':
return wp_nonce_url( admin_url( 'admin-post.php?action=imagify_delete_webp_versions&attachment_id=' . $id . '&context=' . $context ), 'imagify-delete-webp-versions-' . $id . '-' . $context );
case 'delete-nextgen-versions':
return wp_nonce_url( admin_url( 'admin-post.php?action=imagify_delete_nextgen_versions&attachment_id=' . $id . '&context=' . $context ), 'imagify-delete-nextgen-versions-' . $id . '-' . $context );

case 'optimize':
case 'manual-upload': // Deprecated.
Expand Down
Loading