Plugin Updates
This commit is contained in:
@@ -23,8 +23,8 @@ function get_imagify_attachment_optimization_text( $process ) {
|
||||
$output_after = $is_media_page ? '<br/>' : '</li>';
|
||||
$reoptimize_link = get_imagify_attachment_reoptimize_link( $process );
|
||||
$reoptimize_link .= get_imagify_attachment_optimize_missing_thumbnails_link( $process );
|
||||
$reoptimize_link .= get_imagify_attachment_generate_webp_versions_link( $process );
|
||||
$reoptimize_link .= get_imagify_attachment_delete_webp_versions_link( $process );
|
||||
$reoptimize_link .= get_imagify_attachment_generate_nextgen_versions_link( $process );
|
||||
$reoptimize_link .= get_imagify_attachment_delete_nextgen_versions_link( $process );
|
||||
$reoptimize_output = $reoptimize_link ? $reoptimize_link : '';
|
||||
$reoptimize_output_before = '<div class="imagify-datas-actions-links">';
|
||||
$reoptimize_output_after = '</div><!-- .imagify-datas-actions-links -->';
|
||||
@@ -94,12 +94,12 @@ function get_imagify_attachment_optimization_text( $process ) {
|
||||
$output .= $output_before . '<span class="data">' . __( 'Level:', 'imagify' ) . '</span> <strong>' . $optimization_level . '</strong>' . $output_after;
|
||||
|
||||
if ( $media->is_image() ) {
|
||||
$has_webp = $process->has_webp() ? __( 'Yes', 'imagify' ) : __( 'No', 'imagify' );
|
||||
$has_nextgen = $process->has_next_gen() ? __( 'Yes', 'imagify' ) : __( 'No', 'imagify' );
|
||||
|
||||
if ( $process->has_webp() ) {
|
||||
$has_webp = $process->is_full_webp() ? __( 'Yes', 'imagify' ) : __( 'Partially', 'imagify' );
|
||||
if ( $process->has_next_gen() ) {
|
||||
$has_nextgen = $process->is_full_next_gen() ? __( 'Yes', 'imagify' ) : __( 'Partially', 'imagify' );
|
||||
}
|
||||
$output .= $output_before . '<span class="data">' . __( 'WebP generated:', 'imagify' ) . '</span> <strong class="big">' . esc_html( $has_webp ) . '</strong>' . $output_after;
|
||||
$output .= $output_before . '<span class="data">' . __( 'Next-Gen generated:', 'imagify' ) . '</span> <strong class="big">' . esc_html( $has_nextgen ) . '</strong>' . $output_after;
|
||||
|
||||
$total_optimized_thumbnails = $data->get_optimized_sizes_count();
|
||||
|
||||
@@ -317,20 +317,22 @@ function get_imagify_attachment_optimize_missing_thumbnails_link( $process ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the link to generate WebP versions if they are missing.
|
||||
* Get the link to generate next-gen versions if they are missing.
|
||||
*
|
||||
* @since 1.9
|
||||
* @author Grégory Viguier
|
||||
* @since 1.9
|
||||
*
|
||||
* @param ProcessInterface $process The optimization process object.
|
||||
* @return string The output to print.
|
||||
* @param ProcessInterface $process The optimization process object.
|
||||
*
|
||||
* @return string The output to print.
|
||||
*/
|
||||
function get_imagify_attachment_generate_webp_versions_link( $process ) {
|
||||
function get_imagify_attachment_generate_nextgen_versions_link( $process ) {
|
||||
if ( ! $process->is_valid() ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( ! get_imagify_option( 'convert_to_webp' ) ) {
|
||||
$formats = imagify_nextgen_images_formats();
|
||||
|
||||
if ( empty( $formats ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -340,7 +342,13 @@ function get_imagify_attachment_generate_webp_versions_link( $process ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( 'image/webp' === $media->get_mime_type() ) {
|
||||
if (
|
||||
get_imagify_option( 'convert_to_avif' )
|
||||
&&
|
||||
'image/avif' === $media->get_mime_type()
|
||||
) {
|
||||
return '';
|
||||
} elseif ( 'image/webp' === $media->get_mime_type() ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -350,14 +358,16 @@ function get_imagify_attachment_generate_webp_versions_link( $process ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( $process->has_webp() ) {
|
||||
if ( $process->has_next_gen() ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$context = $media->get_context();
|
||||
|
||||
$display = apply_filters_deprecated( 'imagify_display_generate_webp_versions_link', array( true, $process, $context ), '2.2', 'imagify_display_generate_next_gen_versions_link' );
|
||||
|
||||
/**
|
||||
* Allow to not display the "Generate WebP versions" link.
|
||||
* Allow to not display the "Generate next-gen versions" link.
|
||||
*
|
||||
* @since 1.9
|
||||
* @author Grégory Viguier
|
||||
@@ -366,14 +376,14 @@ function get_imagify_attachment_generate_webp_versions_link( $process ) {
|
||||
* @param ProcessInterface $process The optimization process object.
|
||||
* @param string $context The context.
|
||||
*/
|
||||
$display = apply_filters( 'imagify_display_generate_webp_versions_link', true, $process, $context );
|
||||
$display = apply_filters( 'imagify_display_generate_next_gen_versions_link', $display, $process, $context );
|
||||
|
||||
// Stop the process if the filter is false.
|
||||
if ( ! $display ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$url = get_imagify_admin_url( 'generate-webp-versions', [
|
||||
$url = get_imagify_admin_url( 'generate-nextgen-versions', [
|
||||
'attachment_id' => $media->get_id(),
|
||||
'context' => $context,
|
||||
] );
|
||||
@@ -386,7 +396,7 @@ function get_imagify_attachment_generate_webp_versions_link( $process ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the link to delete WebP versions when the status is "already_optimized".
|
||||
* Get the link to delete next-gen versions when the status is "already_optimized".
|
||||
*
|
||||
* @since 1.9.6
|
||||
* @author Grégory Viguier
|
||||
@@ -394,7 +404,7 @@ function get_imagify_attachment_generate_webp_versions_link( $process ) {
|
||||
* @param ProcessInterface $process The optimization process object.
|
||||
* @return string The output to print.
|
||||
*/
|
||||
function get_imagify_attachment_delete_webp_versions_link( $process ) {
|
||||
function get_imagify_attachment_delete_nextgen_versions_link( $process ) {
|
||||
if ( ! $process->is_valid() ) {
|
||||
return '';
|
||||
}
|
||||
@@ -409,12 +419,12 @@ function get_imagify_attachment_delete_webp_versions_link( $process ) {
|
||||
|
||||
$data = $process->get_data();
|
||||
|
||||
if ( ! $data->is_already_optimized() || ! $process->has_webp() ) {
|
||||
if ( ! $data->is_already_optimized() || ! $process->has_next_gen() ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$class = '';
|
||||
$url = get_imagify_admin_url( 'delete-webp-versions', [
|
||||
$url = get_imagify_admin_url( 'delete-nextgen-versions', [
|
||||
'attachment_id' => $media_id,
|
||||
'context' => $context,
|
||||
] );
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -277,14 +277,14 @@ function imagify_bulk_optimize( $contexts, $optimization_level ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the WebP generation
|
||||
* Runs the next-gen generation
|
||||
*
|
||||
* @param array $contexts An array of contexts (WP/Custom folders).
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function imagify_generate_webp( $contexts ) {
|
||||
Imagify\Bulk\Bulk::get_instance()->run_generate_webp( $contexts );
|
||||
function imagify_generate_nextgen( $contexts ) {
|
||||
Imagify\Bulk\Bulk::get_instance()->run_generate_nextgen( $contexts );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -185,6 +185,32 @@ function imagify_path_to_webp( $path ) {
|
||||
return $path . '.webp';
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a path (or URL) to its next-gen version.
|
||||
* To keep the function simple:
|
||||
* - Not tested if it's an image.
|
||||
* - File existance is not tested.
|
||||
* - If an URL is given, make sure it doesn't contain query args.
|
||||
*
|
||||
* @since 2.2
|
||||
*
|
||||
* @param string $path A file path or URL.
|
||||
* @param string $format format we are targeting.
|
||||
* @return string
|
||||
*/
|
||||
function imagify_path_to_nextgen( $path, string $format ) {
|
||||
switch ( $format ) {
|
||||
case 'webp':
|
||||
$path = $path . '.webp';
|
||||
break;
|
||||
case 'avif':
|
||||
$path = $path . '.avif';
|
||||
break;
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the current user can optimize custom folders.
|
||||
*
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use Imagify\Imagifybeat\Actions;
|
||||
use Imagify\Imagifybeat\Core;
|
||||
use Imagify\Stats\OptimizedMediaWithoutWebp;
|
||||
use Imagify\Stats\OptimizedMediaWithoutNextGen;
|
||||
|
||||
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
|
||||
|
||||
@@ -79,27 +79,27 @@ function get_imagify_localize_script_translations( $context ) {
|
||||
],
|
||||
];
|
||||
|
||||
if ( OptimizedMediaWithoutWebp::get_instance()->get_cached_stat() ) {
|
||||
if ( OptimizedMediaWithoutNextGen::get_instance()->get_cached_stat() ) {
|
||||
$contexts = imagify_get_context_names();
|
||||
$translations['bulk'] = [
|
||||
'curlMissing' => ! Imagify_Requirements::supports_curl(),
|
||||
'editorMissing' => ! Imagify_Requirements::supports_image_editor(),
|
||||
'extHttpBlocked' => Imagify_Requirements::is_imagify_blocked(),
|
||||
'apiDown' => ! Imagify_Requirements::is_api_up(),
|
||||
'keyIsValid' => Imagify_Requirements::is_api_key_valid(),
|
||||
'isOverQuota' => Imagify_Requirements::is_over_quota(),
|
||||
'imagifybeatIDs' => [
|
||||
'curlMissing' => ! Imagify_Requirements::supports_curl(),
|
||||
'editorMissing' => ! Imagify_Requirements::supports_image_editor(),
|
||||
'extHttpBlocked' => Imagify_Requirements::is_imagify_blocked(),
|
||||
'apiDown' => ! Imagify_Requirements::is_api_up(),
|
||||
'keyIsValid' => Imagify_Requirements::is_api_key_valid(),
|
||||
'isOverQuota' => Imagify_Requirements::is_over_quota(),
|
||||
'imagifybeatIDs' => [
|
||||
'progress' => $imagifybeat_actions->get_imagifybeat_id( 'options_optimization_status' ),
|
||||
'requirements' => $imagifybeat_actions->get_imagifybeat_id( 'requirements' ),
|
||||
],
|
||||
'ajaxActions' => [
|
||||
'MissingWebp' => 'imagify_missing_webp_generation',
|
||||
'ajaxActions' => [
|
||||
'MissingNextGen' => 'imagify_missing_nextgen_generation',
|
||||
],
|
||||
'ajaxNonce' => wp_create_nonce( 'imagify-bulk-optimize' ),
|
||||
'contexts' => $contexts,
|
||||
'progress_webp' => [
|
||||
'remaining' => OptimizedMediaWithoutWebp::get_instance()->get_stat(),
|
||||
'total' => get_transient( 'imagify_missing_webp_total' ),
|
||||
'ajaxNonce' => wp_create_nonce( 'imagify-bulk-optimize' ),
|
||||
'contexts' => $contexts,
|
||||
'progress_next_gen' => [
|
||||
'remaining' => OptimizedMediaWithoutNextGen::get_instance()->get_stat(),
|
||||
'total' => get_transient( 'imagify_missing_next_gen_total' ),
|
||||
],
|
||||
'labels' => [
|
||||
'curlMissing' => __( 'cURL is not available on the server.', 'imagify' ),
|
||||
@@ -113,8 +113,8 @@ function get_imagify_localize_script_translations( $context ) {
|
||||
'invalidAPIKeyTitle' => __( 'Your API key is not valid!', 'imagify' ),
|
||||
'overQuotaTitle' => __( 'You have used all your credits!', 'imagify' ),
|
||||
'nothingToDoTitle' => __( 'Hold on!', 'imagify' ),
|
||||
'nothingToDoText' => __( 'All your optimized images already have a WebP version. Congratulations!', 'imagify' ),
|
||||
'nothingToDoNoBackupText' => __( 'Because the selected images did not have a backup copy, Imagify was unable to create WebP versions.', 'imagify' ),
|
||||
'nothingToDoText' => __( 'All your optimized images already have a next-gen version. Congratulations!', 'imagify' ),
|
||||
'nothingToDoNoBackupText' => __( 'Because the selected images did not have a backup copy, Imagify was unable to create next-gen versions.', 'imagify' ),
|
||||
'error' => __( 'Error', 'imagify' ),
|
||||
'ajaxErrorText' => __( 'The operation failed.', 'imagify' ),
|
||||
'getUnoptimizedImagesErrorTitle' => __( 'Oops, There is something wrong!', 'imagify' ),
|
||||
@@ -262,7 +262,7 @@ function get_imagify_localize_script_translations( $context ) {
|
||||
'nothingToDoTitle' => __( 'Hold on!', 'imagify' ),
|
||||
'nothingToDoText' => [
|
||||
'optimize' => __( 'All your media files have been optimized by Imagify. Congratulations!', 'imagify' ),
|
||||
'generate_webp' => __( 'All your optimized images already have a WebP version. Congratulations!', 'imagify' ),
|
||||
'generate_webp' => __( 'All your optimized images already have a next-gen version. Congratulations!', 'imagify' ),
|
||||
],
|
||||
'optimizing' => __( 'Optimizing', 'imagify' ),
|
||||
'error' => __( 'Error', 'imagify' ),
|
||||
|
||||
Reference in New Issue
Block a user