| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* JCH Optimize - Performs several front-end optimizations for fast downloads |
| 5 |
* |
| 6 |
* @package jchoptimize/wordpress-platform |
| 7 |
* @author Samuel Marshall <samuel@jch-optimize.net> |
| 8 |
* @copyright Copyright (c) 2023 Samuel Marshall / JCH Optimize |
| 9 |
* @license GNU/GPLv3, or later. See LICENSE file |
| 10 |
* |
| 11 |
* If LICENSE file missing, see <http://www.gnu.org/licenses/>. |
| 12 |
*/ |
| 13 |
|
| 14 |
namespace JchOptimize\WordPress\Controller; |
| 15 |
|
| 16 |
use _JchOptimizeVendor\V91\Joomla\Input\Input; |
| 17 |
use JchOptimize\Core\Model\CacheMaintainer; |
| 18 |
use JchOptimize\Core\Mvc\Controller; |
| 19 |
|
| 20 |
use function json_encode; |
| 21 |
|
| 22 |
class GetCacheInfo extends Controller |
| 23 |
{ |
| 24 |
use AuthorizesAdminRequestsTrait; |
| 25 |
|
| 26 |
public function __construct(private CacheMaintainer $cacheMaintainer, ?Input $input) |
| 27 |
{ |
| 28 |
parent::__construct($input); |
| 29 |
} |
| 30 |
|
| 31 |
public function execute(): bool |
| 32 |
{ |
| 33 |
$this->authorizeAnyCapability(['manage_options', 'jch_clear_page_cache']); |
| 34 |
|
| 35 |
[$size, $numFiles] = $this->cacheMaintainer->getCacheSize(); |
| 36 |
|
| 37 |
$body = json_encode([ |
| 38 |
'size' => $size, |
| 39 |
'numFiles' => $numFiles |
| 40 |
]); |
| 41 |
|
| 42 |
echo $body; |
| 43 |
|
| 44 |
return true; |
| 45 |
} |
| 46 |
} |
| 47 |
|