PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 4.0.26
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v4.0.26
4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.0.30 4.0.29 4.0.28 4.0.27 4.0.26 4.0.24 4.0.25 4.0.23 4.0.22 4.0.21 4.0.19 4.0.18 4.0.17 4.0.16 1.9.3 1.9.4 1.9.5 1.9.6 All 170 releases
searchpro / api / update_configs.php

update_configs.php in BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript 4.0.26, at api/update_configs.php

72 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) exit;
4
5 if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_GET['berqwp_webhook']) && $_GET['berqwp_webhook'] == 'update_configs') {
6
7 if (defined('DOING_CRON') && DOING_CRON) {
8 return;
9 }
10
11 if (defined('DOING_AJAX') && DOING_AJAX) {
12 return;
13 }
14
15 if (defined('REST_REQUEST') && REST_REQUEST) {
16 return;
17 }
18
19 $jsonData = file_get_contents('php://input');
20 $data = json_decode($jsonData, true);
21
22 if ($data == null) {
23 return;
24 }
25
26 $settings = (array) $data['settings'];
27 $license_key_hash = sanitize_text_field($data['license_key_hash']);
28 $license_key = berqwp_get_license_key();
29
30 if (empty($license_key_hash) || empty($license_key) || $license_key_hash !== md5($license_key)) {
31 echo json_encode(['status' => 'error']);
32 http_response_code(403);
33 exit;
34 }
35
36 if (empty($settings)) {
37 return;
38 }
39
40 // Sanitize
41 $valid_setting_names = [
42 'berqwp_fluid_images',
43 'berqwp_can_use_fluid_images',
44 'berqwp_license_key',
45 ];
46
47 foreach ($settings as $setting_name => $setting_value) {
48
49 // skip invalid name
50 if (!in_array($setting_name, $valid_setting_names)) {
51 continue;
52 }
53
54 switch ($setting_name) {
55
56 case 'berqwp_can_use_fluid_images':
57 update_option($setting_name, $setting_value);
58 update_option('bwp_require_flush_cache', 1);
59 break;
60
61 case 'berqwp_license_key':
62 update_option($setting_name, $setting_value);
63 break;
64
65 }
66
67
68 }
69
70
71 exit;
72 }