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

@@ -124,7 +124,7 @@ class NGG extends AbstractBulk {
$data_table = DB::get_instance()->get_table_name();
$suffix = constant( imagify_get_optimization_process_class_name( 'ngg' ) . '::WEBP_SUFFIX' );
if ( get_imagify_option( 'convert_to_avif' ) ) {
if ( 'avif' === get_imagify_option( 'optimization_format' ) ) {
$suffix = constant( imagify_get_optimization_process_class_name( 'ngg' ) . '::AVIF_SUFFIX' );
}
@@ -194,7 +194,7 @@ class NGG extends AbstractBulk {
$data_table = DB::get_instance()->get_table_name();
$suffix = constant( imagify_get_optimization_process_class_name( 'ngg' ) . '::WEBP_SUFFIX' );
if ( get_imagify_option( 'convert_to_avif' ) ) {
if ( 'avif' === get_imagify_option( 'optimization_format' ) ) {
$suffix = constant( imagify_get_optimization_process_class_name( 'ngg' ) . '::AVIF_SUFFIX' );
}

View File

@@ -291,7 +291,7 @@ function _imagify_new_upgrade( $network_version, $site_version ) {
// 1.8.2
if ( version_compare( $site_version, '1.8.2' ) < 0 ) {
Imagify_Options::get_instance()->set( 'partner_links', 1 );
$options->set( 'partner_links', 1 );
}
// 1.9.6
@@ -305,12 +305,20 @@ function _imagify_new_upgrade( $network_version, $site_version ) {
}
if ( version_compare( $site_version, '2.0' ) < 0 ) {
Imagify_Options::get_instance()->set( 'optimization_level', 2 );
$options->set( 'optimization_level', 2 );
}
if ( version_compare( $site_version, '2.2' ) < 0 ) {
Imagify_Options::get_instance()->set( 'display_nextgen', Imagify_Options::get_instance()->get( 'display_webp', 0 ) );
Imagify_Options::get_instance()->set( 'display_nextgen_method', Imagify_Options::get_instance()->get( 'display_webp_method' ) );
$options->set( 'display_nextgen', $options->get( 'display_webp', 0 ) );
$options->set( 'display_nextgen_method', $options->get( 'display_webp_method' ) );
}
if ( version_compare( $site_version, '2.2.2', '<' ) ) {
if ( $options->get( 'convert_to_avif' ) ) {
$options->set( 'optimization_format', 'avif' );
} else {
$options->set( 'optimization_format', 'webp' );
}
}
}
add_action( 'imagify_upgrade', '_imagify_new_upgrade', 10, 2 );

View File

@@ -1,6 +1,10 @@
<?php
defined( 'ABSPATH' ) || die( 'Cheatin uh?' );
if ( ! class_exists( 'WP_List_Table' ) ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
}
/**
* Class that display the "custom folders" files.
*

View File

@@ -44,6 +44,7 @@ class Imagify_Options extends Imagify_Abstract_Options {
'partner_links' => 0,
'convert_to_avif' => 0,
'convert_to_webp' => 0,
'optimization_format' => 'webp',
];
/**
@@ -96,10 +97,6 @@ class Imagify_Options extends Imagify_Abstract_Options {
parent::__construct();
}
/** ----------------------------------------------------------------------------------------- */
/** SANITIZATION, VALIDATION ================================================================ */
/** ----------------------------------------------------------------------------------------- */
/**
* Sanitize and validate an option value. Basic casts have been made.
*
@@ -127,7 +124,13 @@ class Imagify_Options extends Imagify_Abstract_Options {
return $reset_values[ $key ];
}
return $value;
case 'optimization_format':
if ( ! in_array( $value, [ 'off', 'webp', 'avif' ], true ) ) {
// For an invalid value, return the "reset" value.
$reset_values = $this->get_reset_values();
return $reset_values[ $key ];
}
return $value;
case 'auto_optimize':
case 'backup':
case 'lossless':

View File

@@ -748,6 +748,74 @@ class Imagify_Settings {
<?php
}
/**
* Display styled radio list group.
*
* @param array $args Arguments:
* {option_name} string The option name. E.g. 'disallowed-sizes'. Mandatory.
* {values} array List of values to display, in the form of 'value' => 'Label'. Mandatory.
* {attributes} array A list of HTML attributes, as 'attribute' => 'value'.
* {current_value} int|bool USE ONLY WHEN DEALING WITH DATA THAT IS NOT SAVED IN THE PLUGIN OPTIONS. If not provided, the field will automatically get the value from the options.
*
* @return void
*/
public function field_inline_radio_list( $args ) {
$args = array_merge(
[
'option_name' => '',
'values' => [],
'info' => '',
'attributes' => [],
'current_value' => false,
],
$args
);
if ( ! $args['option_name'] || ! $args['values'] ) {
return;
}
if ( is_numeric( $args['current_value'] ) || is_string( $args['current_value'] ) ) {
$current_value = $args['current_value'];
} else {
$current_value = $this->options->get( $args['option_name'] );
}
$option_name_class = sanitize_html_class( $args['option_name'] );
$attributes = array_merge( [
'name' => $this->option_name . '[' . $args['option_name'] . ']',
'id' => 'imagify_' . $option_name_class . '_%s',
'class' => 'imagify-row-radio',
], $args['attributes'] );
$id_attribute = $attributes['id'];
unset( $attributes['id'] );
$args['attributes'] = self::build_attributes( $attributes );
?>
<div class="imagify-setting-optim-level">
<p class="imagify-inline-options imagify-inline-options-<?php echo esc_attr( $args['info_class'] ); ?>">
<?php
foreach ( $args['values'] as $value => $label ) {
$input_id = sprintf( $id_attribute, sanitize_html_class( $value ) );
?>
<input type="radio" value="<?php echo esc_attr( $value ); ?>" id="<?php echo $input_id; ?>"<?php echo $args['attributes']; ?> <?php checked( $current_value, $value ); ?> />
<label for="<?php echo $input_id; ?>" onclick=""><?php echo $label; ?></label>
<?php
}
?>
</p>
<span id="<?php
echo $attributes['aria-describedby'];
?>" class="imagify-<?php echo esc_attr( $args['info_class'] ); ?>">
<span class="dashicons dashicons-info"></span>
<?php
echo $args['info'];
?>
</span>
</div>
<?php
}
/**
* Display a text box.
*

View File

@@ -75,14 +75,11 @@ add_filter( 'big_image_size_threshold', [ imagify_get_context( 'wp' ), 'get_resi
* @return array
*/
function imagify_nextgen_images_formats() {
$formats = [
'webp' => 'webp',
];
$value = get_imagify_option( 'optimization_format' );
$formats = [];
if ( get_imagify_option( 'convert_to_avif' ) ) {
$formats['avif'] = 'avif';
unset( $formats['webp'] );
if ( 'off' !== $value ) {
$formats[ $value ] = $value;
}
$default = $formats;

View File

@@ -342,8 +342,10 @@ function get_imagify_attachment_generate_nextgen_versions_link( $process ) {
return '';
}
$format = get_imagify_option( 'optimization_format' );
if (
get_imagify_option( 'convert_to_avif' )
'avif' === $format
&&
'image/avif' === $media->get_mime_type()
) {