PluginProbe
QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress / 3.2.6
QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress v3.2.6
4.1.1 4.1.0 4.0.1 4.0.0 3.3.1 3.3.0 trunk 1.0.0 2.0.0 2.1.0 3.0.0 3.1.0 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8
quickwebp / admin / rewrite-rules / class-nginx.php

class-nginx.php in QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress 3.2.6, at admin/rewrite-rules/class-nginx.php

49 lines 993 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 include_once QUICKWEBP_PLUGIN_PATH . 'admin/rewrite-rules/class-rewrite-rules-abstract.php';
4
5 class Nginx extends Rewrite_Rules_Abstract {
6
7 /**
8 * Get the path to the file.
9 */
10 protected function get_file_path() {
11 $file_path = $this->get_site_root() . 'conf/quickwebp.conf';
12
13 return $file_path;
14 }
15
16 /**
17 * Get unfiltered new contents to write into the file.
18 *
19 * @since 1.9
20 * @access protected
21 * @author Grégory Viguier
22 *
23 * @return string
24 */
25 protected function get_raw_new_contents() {
26 $extensions = 'jpg|jpeg|jpe|png';
27 $home_root = wp_parse_url( home_url( '/' ) );
28 $home_root = $home_root['path'];
29
30 return trim( '
31 # BEGIN ' . $this->tag_name . '
32 location ~* ^(' . $home_root . '.+)\.(' . $extensions . ')$ {
33 add_header Vary Accept;
34
35 if ($http_accept ~* "webp"){
36 set $imwebp A;
37 }
38 if (-f $request_filename.webp) {
39 set $imwebp "${imwebp}B";
40 }
41 if ($imwebp = AB) {
42 rewrite ^(.*) $1.webp;
43 }
44 }
45 # END ' . $this->tag_name . '');
46 }
47
48
49 }