Edit File by line
/home/zeestwma/ajeebong.../wp-conte.../plugins/image-op.../modules/settings/classes
File: settings.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace ImageOptimization\Modules\Settings\Classes;
[2] Fix | Delete
[3] Fix | Delete
use ImageOptimization\Classes\Image\Image_Conversion_Option;
[4] Fix | Delete
[5] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[6] Fix | Delete
exit; // Exit if accessed directly.
[7] Fix | Delete
}
[8] Fix | Delete
[9] Fix | Delete
class Settings {
[10] Fix | Delete
public const COMPRESSION_LEVEL_OPTION_NAME = 'image_optimizer_compression_level';
[11] Fix | Delete
public const OPTIMIZE_ON_UPLOAD_OPTION_NAME = 'image_optimizer_optimize_on_upload';
[12] Fix | Delete
/** @deprecated Use self::CONVERT_TO_FORMAT_OPTION_NAME instead */
[13] Fix | Delete
public const CONVERT_TO_WEBP_OPTION_NAME = 'image_optimizer_convert_to_webp';
[14] Fix | Delete
public const CONVERT_TO_FORMAT_OPTION_NAME = 'image_optimizer_convert_to_format';
[15] Fix | Delete
public const RESIZE_LARGER_IMAGES_OPTION_NAME = 'image_optimizer_resize_larger_images';
[16] Fix | Delete
public const RESIZE_LARGER_IMAGES_SIZE_OPTION_NAME = 'image_optimizer_resize_larger_images_size';
[17] Fix | Delete
public const STRIP_EXIF_METADATA_OPTION_NAME = 'image_optimizer_exif_metadata';
[18] Fix | Delete
public const BACKUP_ORIGINAL_IMAGES_OPTION_NAME = 'image_optimizer_original_images';
[19] Fix | Delete
public const CUSTOM_SIZES_OPTION_NAME = 'image_optimizer_custom_sizes';
[20] Fix | Delete
public const SUPPORT_BIG_FILES = 'image_optimizer_support_big_files';
[21] Fix | Delete
public const HELP_VIDEOS = 'image_optimizer_help_videos';
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* Returns plugin settings data by option name typecasted to an appropriate data type.
[25] Fix | Delete
*
[26] Fix | Delete
* @param string $option_name
[27] Fix | Delete
* @return mixed
[28] Fix | Delete
*/
[29] Fix | Delete
public static function get( string $option_name ) {
[30] Fix | Delete
$data = get_option( $option_name );
[31] Fix | Delete
[32] Fix | Delete
switch ( $option_name ) {
[33] Fix | Delete
case self::RESIZE_LARGER_IMAGES_SIZE_OPTION_NAME:
[34] Fix | Delete
return (int) $data;
[35] Fix | Delete
[36] Fix | Delete
case self::RESIZE_LARGER_IMAGES_OPTION_NAME:
[37] Fix | Delete
case self::STRIP_EXIF_METADATA_OPTION_NAME:
[38] Fix | Delete
case self::BACKUP_ORIGINAL_IMAGES_OPTION_NAME:
[39] Fix | Delete
return (bool) $data;
[40] Fix | Delete
[41] Fix | Delete
// TODO: [Stability] Remove this fallback after a few versions
[42] Fix | Delete
case self::CONVERT_TO_WEBP_OPTION_NAME:
[43] Fix | Delete
$new_option = get_option( self::CONVERT_TO_FORMAT_OPTION_NAME );
[44] Fix | Delete
[45] Fix | Delete
if ( Image_Conversion_Option::WEBP === $new_option ) {
[46] Fix | Delete
return true;
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
return false;
[50] Fix | Delete
[51] Fix | Delete
case self::CUSTOM_SIZES_OPTION_NAME:
[52] Fix | Delete
if ( 'all' === $data ) {
[53] Fix | Delete
return $data;
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
if ( empty( $data ) ) {
[57] Fix | Delete
return [];
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
return explode( ',', $data );
[61] Fix | Delete
[62] Fix | Delete
default:
[63] Fix | Delete
return $data;
[64] Fix | Delete
}
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
public static function set( string $option_name, $value ): bool {
[68] Fix | Delete
return update_option( $option_name, $value, false );
[69] Fix | Delete
}
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function