PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 1.9.6
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v1.9.6
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 / store_webp.php

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

21 lines 639 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH'))
3 exit;
4
5 $webp_img = base64_decode($request->get_param('image'));
6 $webp_url = sanitize_text_field($request->get_param('url'));
7 $webp_path = str_replace(get_site_url(), ABSPATH, $webp_url);
8
9 // Validate file extension
10 $valid_extensions = ['jpg', 'jpeg', 'png', 'webp', 'svg'];
11 $url_path = parse_url($webp_url, PHP_URL_PATH);
12 $file_extension = strtolower(pathinfo($url_path, PATHINFO_EXTENSION));
13
14 // Check the file extension
15 if (!in_array($file_extension, $valid_extensions)) {
16 return false;
17 }
18
19 // Save the image to the specified path
20 $store = file_put_contents($webp_path, $webp_img);
21 unset($webp_img);