tenweb-speed-optimizer
/
vendor
/
10web-utils
/
tenweb-image-optimizer
/
src
/
TenWebIO
/
LastCompress.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
LastCompress.php
71 lines
| 1 | <?php |
| 2 | namespace TenWebIO; |
| 3 | |
| 4 | class LastCompress |
| 5 | { |
| 6 | private $image_size = 0; |
| 7 | private $image_orig_size = 0; |
| 8 | private $count = 0; |
| 9 | |
| 10 | /** |
| 11 | * @param $force |
| 12 | */ |
| 13 | public function __construct($force = false) |
| 14 | { |
| 15 | if (!$force) { |
| 16 | $data = get_site_option(TENWEBIO_PREFIX . '_last_compress_data'); |
| 17 | if (!empty($data)) { |
| 18 | if (!empty($data['image_size'])) { |
| 19 | $this->image_size = $data['image_size']; |
| 20 | } |
| 21 | if (!empty($data['image_orig_size'])) { |
| 22 | $this->image_orig_size = $data['image_orig_size']; |
| 23 | } |
| 24 | if (!empty($data['count'])) { |
| 25 | $this->count = $data['count']; |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * @param $image_size |
| 33 | * @param $image_orig_size |
| 34 | * @param $count |
| 35 | * |
| 36 | * @return void |
| 37 | */ |
| 38 | public function update($image_size, $image_orig_size, $count = 1) |
| 39 | { |
| 40 | update_site_option(TENWEBIO_PREFIX . '_last_compress_data', array( |
| 41 | "image_size" => $this->image_size + $image_size, |
| 42 | "image_orig_size" => $this->image_orig_size + $image_orig_size, |
| 43 | "count" => $this->count + $count, |
| 44 | )); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * @return int |
| 49 | */ |
| 50 | public function getImageSize() |
| 51 | { |
| 52 | return $this->image_size; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * @return int |
| 57 | */ |
| 58 | public function getImageOrigSize() |
| 59 | { |
| 60 | return $this->image_orig_size; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * @return int |
| 65 | */ |
| 66 | public function getCount() |
| 67 | { |
| 68 | return $this->count; |
| 69 | } |
| 70 | |
| 71 | } |