auto-patch 638-dev-dev01-2024-05-14T20_44_36

This commit is contained in:
root
2024-05-14 20:44:36 +00:00
parent a941559057
commit 5dbb0b284e
1812 changed files with 29671 additions and 14588 deletions

View File

@@ -112,10 +112,10 @@ abstract class AbstractBulk implements BulkInterface {
* @return int The number of media.
*/
public function has_optimized_media_without_nextgen() {
$format = 'webp';
$format = get_imagify_option( 'optimization_format' );
if ( get_imagify_option( 'convert_to_avif' ) ) {
$format = 'avif';
if ( 'off' === $format ) {
return 0;
}
return count( $this->get_optimized_media_ids_without_format( $format )['ids'] );

View File

@@ -586,11 +586,20 @@ class Bulk {
* @return void
*/
public function maybe_generate_missing_nextgen( $old_value, $value ) {
if ( empty( $old_value['convert_to_avif'] ) === empty( $value['convert_to_avif'] ) ) {
if ( ! isset( $old_value['optimization_format'], $value['optimization_format'] ) ) {
return;
}
if ( $old_value['optimization_format'] === $value['optimization_format'] ) {
// Old value = new value so do nothing.
return;
}
if ( 'off' === $value['optimization_format'] ) {
// No need to generate next-gen images.
return;
}
$contexts = $this->get_contexts();
$formats = imagify_nextgen_images_formats();

View File

@@ -182,10 +182,10 @@ class Actions {
$bulk = Bulk::get_instance();
$format = 'webp';
$format = get_imagify_option( 'optimization_format' );
if ( get_imagify_option( 'convert_to_avif' ) ) {
$format = 'avif';
if ( 'off' === $format ) {
return $response;
}
foreach ( $data[ $imagifybeat_id ] as $context ) {

View File

@@ -745,10 +745,9 @@ class File {
/**
* Get the file extension.
*
* @since 1.9
* @author Grégory Viguier
* @since 1.9
*
* @return string|null
* @return string|false
*/
public function get_extension() {
return $this->get_file_type()->ext;

View File

@@ -581,11 +581,21 @@ abstract class AbstractProcess implements ProcessInterface {
// This file type is not supported.
$extension = $file->get_extension();
if ( '' === $extension ) {
if ( ! $extension ) {
$response = new WP_Error(
'extension_not_mime',
__( 'This file has an extension that does not match a mime type.', 'imagify' )
);
} elseif ( '' === $extension ) {
$response = new WP_Error(
'no_extension',
__( 'With no extension, this file cannot be optimized.', 'imagify' )
);
} elseif ( ! $extension ) {
$response = new WP_Error(
'extension_not_mime',
__( 'This file has an extension that does not match a mime type.', 'imagify' )
);
} else {
$response = new WP_Error(
'extension_not_supported',
@@ -1532,7 +1542,9 @@ abstract class AbstractProcess implements ProcessInterface {
* @return string Current format we are targeting.
*/
public function get_current_format() {
return $this->get_option( 'convert_to_avif' ) ? static::AVIF_SUFFIX : static::WEBP_SUFFIX;
$format = get_imagify_option( 'optimization_format' );
return ( 'avif' === $format ) ? static::AVIF_SUFFIX : static::WEBP_SUFFIX;
}
/**
@@ -1551,7 +1563,7 @@ abstract class AbstractProcess implements ProcessInterface {
foreach ( $formats as $format ) {
$suffix = preg_quote( $this->get_suffix_from_format( $format ), '/' );
if ( preg_match( '/^(?<size>.+)' . $suffix . '$/', $size_name, $matches ) ) {
if ( preg_match( '/^(?<size>.+)' . $suffix . '$/', (string) $size_name, $matches ) ) {
return $matches['size'];
}
}

View File

@@ -107,7 +107,7 @@ class OptimizedMediaWithoutNextGen implements StatInterface, SubscriberInterface
$new_sizes = array_intersect_key( $sizes, $new_sizes );
$size_name = 'full' . $process::WEBP_SUFFIX;
if ( get_imagify_option( 'convert_to_avif' ) ) {
if ( 'avif' === get_imagify_option( 'optimization_format' ) ) {
$size_name = 'full' . $process::AVIF_SUFFIX;
}
@@ -147,7 +147,7 @@ class OptimizedMediaWithoutNextGen implements StatInterface, SubscriberInterface
$sizes = isset( $data['sizes'] ) ? (array) $data['sizes'] : [];
$size_name = 'full' . $process::WEBP_SUFFIX;
if ( get_imagify_option( 'convert_to_avif' ) ) {
if ( 'avif' === get_imagify_option( 'optimization_format' ) ) {
$size_name = 'full' . $process::AVIF_SUFFIX;
}
@@ -175,7 +175,7 @@ class OptimizedMediaWithoutNextGen implements StatInterface, SubscriberInterface
$sizes = isset( $data['sizes'] ) ? (array) $data['sizes'] : [];
$size_name = 'full' . $process::WEBP_SUFFIX;
if ( get_imagify_option( 'convert_to_avif' ) ) {
if ( 'avif' === get_imagify_option( 'optimization_format' ) ) {
$size_name = 'full' . $process::AVIF_SUFFIX;
}
@@ -198,11 +198,11 @@ class OptimizedMediaWithoutNextGen implements StatInterface, SubscriberInterface
* @return void
*/
public function maybe_clear_stat_cache( $old_value, $value ) {
if ( isset( $old_value['convert_to_avif'] ) && isset( $value['convert_to_avif'] ) ) {
if ( ! isset( $old_value['optimization_format'], $value['optimization_format'] ) ) {
return;
}
if ( ! isset( $old_value['convert_to_avif'] ) && ! isset( $value['convert_to_avif'] ) ) {
if ( $old_value['optimization_format'] === $value['optimization_format'] ) {
return;
}