tenweb-speed-optimizer
/
vendor
/
10web-utils
/
tenweb-image-optimizer
/
src
/
TenWebIO
/
Config.php
tenweb-speed-optimizer
/
vendor
/
10web-utils
/
tenweb-image-optimizer
/
src
/
TenWebIO
Last commit date
Exceptions
4 years ago
Queue
2 years ago
Views
2 years ago
Api.php
2 years ago
Attachments.php
2 years ago
Backup.php
2 years ago
CLI.php
3 years ago
Compress.php
2 years ago
CompressDataService.php
3 years ago
CompressService.php
3 years ago
Config.php
2 years ago
Init.php
2 years ago
LastCompress.php
3 years ago
Logs.php
2 years ago
PreInit.php
3 years ago
Rest.php
2 years ago
Settings.php
3 years ago
Utils.php
1 year ago
Config.php
111 lines
| 1 | <?php |
| 2 | namespace TenWebIO; |
| 3 | |
| 4 | class Config |
| 5 | { |
| 6 | private $debug_mode = 0; |
| 7 | private $images_limit_for_restart = 20; |
| 8 | private $auto_optimize_with_rest = 1; |
| 9 | private $queue_chunk_images_limit = 1000; |
| 10 | private $stat_chunk_images_limit = 500000; |
| 11 | private $compress_only_full_size = 0; |
| 12 | |
| 13 | public function __construct() |
| 14 | { |
| 15 | $config = get_site_option(TENWEBIO_PREFIX . '_configs'); |
| 16 | if (!empty($config['debug_mode'])) { |
| 17 | $this->debug_mode = (int)$config['debug_mode']; |
| 18 | } else { |
| 19 | $this->debug_mode = 0; |
| 20 | } |
| 21 | if (!empty($config['auto_optimize_with_rest'])) { |
| 22 | $this->auto_optimize_with_rest = (int)$config['auto_optimize_with_rest']; |
| 23 | } else { |
| 24 | $this->auto_optimize_with_rest = 1; |
| 25 | } |
| 26 | |
| 27 | if (!empty($config['images_limit_for_restart'])) { |
| 28 | $this->images_limit_for_restart = (int)$config['images_limit_for_restart']; |
| 29 | } |
| 30 | |
| 31 | if (!empty($config['queue_chunk_images_limit'])) { |
| 32 | $this->queue_chunk_images_limit = (int)$config['queue_chunk_images_limit']; |
| 33 | } |
| 34 | |
| 35 | if (!empty($config['stat_chunk_images_limit'])) { |
| 36 | $this->stat_chunk_images_limit = (int)$config['stat_chunk_images_limit']; |
| 37 | } |
| 38 | if (!empty($config['compress_only_full_size'])) { |
| 39 | $this->compress_only_full_size = (int)$config['compress_only_full_size']; |
| 40 | } else { |
| 41 | $this->compress_only_full_size = 0; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | public function getDebugMode() |
| 46 | { |
| 47 | return $this->debug_mode; |
| 48 | } |
| 49 | |
| 50 | public function getImagesLimitForRestart() |
| 51 | { |
| 52 | return $this->images_limit_for_restart; |
| 53 | } |
| 54 | |
| 55 | public function getAutoOptimizeWithRest() |
| 56 | { |
| 57 | return $this->auto_optimize_with_rest; |
| 58 | } |
| 59 | |
| 60 | public function getQueueChunkImagesLimit() |
| 61 | { |
| 62 | return $this->queue_chunk_images_limit; |
| 63 | } |
| 64 | |
| 65 | public function getStatChunkImagesLimit() |
| 66 | { |
| 67 | return $this->stat_chunk_images_limit; |
| 68 | } |
| 69 | |
| 70 | public function getCompressOnlyFullSize() |
| 71 | { |
| 72 | return $this->compress_only_full_size; |
| 73 | } |
| 74 | |
| 75 | public function save($data) |
| 76 | { |
| 77 | if (isset($data['debug_mode'])) { |
| 78 | $this->debug_mode = 1; |
| 79 | } else { |
| 80 | $this->debug_mode = 0; |
| 81 | } |
| 82 | if (isset($data['images_limit_for_restart'])) { |
| 83 | $this->images_limit_for_restart = (int)$data['images_limit_for_restart']; |
| 84 | } |
| 85 | if (isset($data['auto_optimize_with_rest'])) { |
| 86 | $this->auto_optimize_with_rest = 1; |
| 87 | } else { |
| 88 | $this->auto_optimize_with_rest = 0; |
| 89 | } |
| 90 | if (isset($data['queue_chunk_images_limit'])) { |
| 91 | $this->queue_chunk_images_limit = (int)$data['queue_chunk_images_limit']; |
| 92 | } |
| 93 | if (isset($data['stat_chunk_images_limit'])) { |
| 94 | $this->stat_chunk_images_limit = (int)$data['stat_chunk_images_limit']; |
| 95 | } |
| 96 | if (isset($data['compress_only_full_size'])) { |
| 97 | $this->compress_only_full_size = 1; |
| 98 | } else { |
| 99 | $this->compress_only_full_size = 0; |
| 100 | } |
| 101 | update_site_option(TENWEBIO_PREFIX . '_configs', array( |
| 102 | 'debug_mode' => $this->debug_mode, |
| 103 | 'images_limit_for_restart' => $this->images_limit_for_restart, |
| 104 | 'auto_optimize_with_rest' => $this->auto_optimize_with_rest, |
| 105 | 'queue_chunk_images_limit' => $this->queue_chunk_images_limit, |
| 106 | 'stat_chunk_images_limit' => $this->stat_chunk_images_limit, |
| 107 | 'compress_only_full_size' => $this->compress_only_full_size, |
| 108 | )); |
| 109 | } |
| 110 | |
| 111 | } |