PluginProbe
JCH Optimize / trunk
JCH Optimize vtrunk
6.0.2 6.0.1 trunk 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0 1.2.1 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.1.0 2.10.0 2.2.0 2.2.1 All 58 releases
jch-optimize / src / Controller / ApplyAutoSetting.php

ApplyAutoSetting.php in JCH Optimize trunk, at src/Controller/ApplyAutoSetting.php

50 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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) 2021 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\Mvc\Controller;
18 use JchOptimize\WordPress\Model\Configure;
19
20 use function json_encode;
21
22 class ApplyAutoSetting extends Controller
23 {
24 use AuthorizesAdminRequestsTrait;
25
26 public function __construct(private Configure $model, ?Input $input)
27 {
28 parent::__construct($input);
29 }
30
31 public function execute(): bool
32 {
33 $this->authorizeManageOptions();
34 /** @var Input $input */
35 $input = $this->getInput();
36 $setting = (string)$input->get('autosetting', 's1');
37
38 if (!check_ajax_referer($setting, false, false)) {
39 echo json_encode(['success' => false]);
40 return false;
41 }
42
43 $this->model->applyAutoSetting($setting);
44
45 echo json_encode(['success' => true]);
46
47 return true;
48 }
49 }
50