PluginProbe
QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress / 3.3.0
QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress v3.3.0
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-iis.php

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

58 lines 1.8 KB
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
6 class IIS extends Rewrite_Rules_Abstract {
7
8 /**
9 * Get the path to the file.
10 */
11 protected function get_file_path() {
12 $file_path = $this->get_site_root() . 'web.config';
13
14 return $file_path;
15 }
16
17 /**
18 * Get unfiltered new contents to write into the file.
19 */
20 protected function get_raw_new_contents() {
21 $extensions = 'jpg|jpeg|jpe|png';
22 $home_root = wp_parse_url( home_url( '/' ) );
23 $home_root = $home_root['path'];
24
25 return trim( '
26 # BEGIN ' . $this->tag_name . '
27 <!-- @parent /configuration/system.webServer/rewrite/rules -->
28 <rule name="' . esc_attr( $this->tag_name ) . ' 2">
29 <match url="^(' . $home_root . '.+)\.(' . $extensions . ')$" ignoreCase="true" />
30 <conditions logicalGrouping="MatchAll">
31 <add input="{HTTP_ACCEPT}" pattern="image/webp" ignoreCase="false" />
32 <add input="{DOCUMENT_ROOT}/{R:1}{R:2}.webp" matchType="IsFile" />
33 </conditions>
34 <action type="Rewrite" url="{R:1}{R:2}.webp" logRewrittenUrl="true" />
35 <serverVariables>
36 <set name="ACCEPTS_WEBP" value="true" />
37 </serverVariables>
38 </rule>
39
40 <!-- @parent /configuration/system.webServer/rewrite/outboundRules -->
41 <rule preCondition="IsWebp" name="' . esc_attr( $this->tag_name ) . ' 3">
42 <match serverVariable="RESPONSE_Vary" pattern=".*" />
43 <action type="Rewrite" value="Accept"/>
44 </rule>
45 <preConditions name="' . esc_attr( $this->tag_name ) . ' 4">
46 <preCondition name="IsWebp">
47 <add input="{ACCEPTS_WEBP}" pattern="true" ignoreCase="false" />
48 </preCondition>
49 </preConditions>
50
51 <!-- @parent /configuration/system.webServer -->
52 <staticContent name="' . esc_attr( $this->tag_name ) . ' 1">
53 <mimeMap fileExtension=".webp" mimeType="image/webp" />
54 </staticContent>
55 # END ' . $this->tag_name . '');
56 }
57
58 }