auto-patch 638-dev-dev01-2024-05-14T20_44_36
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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':
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user